javascript - How to get the src of img tag using jquery -


i have html follow :

<ul class="thumbnails">     <li><a class="thumbnail" href="http://localhost/upload/image/cache/catalog/demo/canon_eos_5d_1-500x500.jpg" title="canon eos 5d"><img src="http://localhost/upload/image/cache/catalog/demo/canon_eos_5d_1-228x228.jpg" title="canon eos 5d" alt="canon eos 5d"></a></li>     <li class="image-additional"><a class="thumbnail" href="http://localhost/upload/image/cache/catalog/demo/canon_eos_5d_2-500x500.jpg" title="canon eos 5d"> <img src="http://localhost/upload/image/cache/catalog/demo/canon_eos_5d_2-74x74.jpg" title="canon eos 5d" alt="canon eos 5d"></a></li>     <li class="image-additional"><a class="thumbnail" href="http://localhost/upload/image/cache/catalog/demo/canon_eos_5d_3-500x500.jpg" title="canon eos 5d"> <img src="http://localhost/upload/image/cache/catalog/demo/canon_eos_5d_3-74x74.jpg" title="canon eos 5d" alt="canon eos 5d"></a></li> </ul> 

i want src value img. have used following code :

var imgtag =  $('.thumbnail').attr("href");         console.log(imgtag); 

it gives href of a tag want src of img tag after a tag modification should ?

image child element of .thumbnail. need use:

$('.thumbnail').find('img').attr("src"); 

change src of image:

 $('.thumbnail').find('img').attr("src", newsrc); 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -