jquery - Can I get the image and load via ajax into div -


i have code below , need load image href div via ajax... appreciated. believe load() can't load images this?

    <ul id="list">     <li class="list-item-1"><a href="images/image1.jpg">image 1</a></li>     <li class="list-item-2"><a href="images/image2.jpg">image 2</a></li>     <li class="list-item-3"><a href="images/image3.jpg">image 3</a></li>     <li class="list-item-4"><a href="images/image4.jpg">image 4</a></li>     </ul> <div id="image-holder"></div> 

many thanks, c

you have remove appended image. here click event , image instead of appending markup.

$('#list li a').click(function () {     var url = $(this).attr('href'),     image = new image();     image.src = url;     image.onload = function () {         $('#image-holder').empty().append(image);     };     image.onerror = function () {         $('#image-holder').empty().html('that image not available.');     }      $('#image-holder').empty().html('loading...');      return false; }); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -