Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change the "width" & "height" attribute on an IMG tag?

<div class="moviesRotator" id="moviesRotator">
<a>
<img width="431" height="348" alt="" src="img_url1"/>
</a>
<a>
<img width="431" height="348" alt="" src="img_url2"/>
</a>
<a>
<img width="431" height="348" alt="" src="img_url3"/>
</a>
</div>

I want to make the image wider, and bigger dynamically. So is it possible to do this?

$('.moviesRotat0r.a.img').attr('width', 620)
$('.moviesRotat0r.a.img').attr('height', 380)

So is it possible to iterate through all the tags within the and change the height and width that way?

What is the correct syntax here?

Please let me know.

many thanks.

like image 901
doglin Avatar asked Nov 30 '25 16:11

doglin


1 Answers

You can do this ... Make sure the source of images are large enough to avoid enlargement artefacts ...

$('.moviesRotator img').attr('width', 620).attr('height', 380);

Use the container's id instead if available (search is faster)

$('#moviesRotator img').attr('width', 620).attr('height', 380);
like image 133
Stphane Avatar answered Dec 03 '25 08:12

Stphane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!