Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

dynamically Adding options to a "select" using jQuery/JavaScript

Personally, I prefer this syntax for appending options:
$('#mySelect').append($(', {
    value: 1,
    text: 'My option'
}));
If you're adding options from a collection of items, you can do the following:
$.each(items, function (i, item) {
    $('#mySelect').append($(', { 
        value: item.value,
        text : item.text 
    }));
});

How to load external font in css




How how to use in your code

.your-div-name {
  1. font-familymyFirstFont;

lazyload Image

JQuery

$(window).bind("load", function(){
 var timeout = setTimeout(function() {
  $('.lazyload1second').each(function(){      
   $(this).attr('src', $(this).attr('original_link')).fadeIn(700);
   $(this).removeAttr('original_link');   
  });
 }, 500);
});

HTML

width="100%"  src="//www.example.com/images/right_banner_loader.jpg" original_link="https://example.blob.core.windows.net/images/offers/website.jpg?v3=3" alt="True Rupees" class="lazyload1second">


Display Image Preview Be four Uploading Image.

See Live Demo.

http://stackoverflow.com/a/12369027


HTML



   type='file' onchange="readURL(this);" />
     id="blah" src="#" alt="your image" />

JQuery
function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#blah')
                    .attr('src', e.target.result)
                    .width(150)
                    .height(200);
            };

            reader.readAsDataURL(input.files[0]);
        }
}