Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Change img size

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35319
    XaviJr
    Participant

    I’m doing this resize of images with jquery and I wasn’t able to change the width of the img inside a li tag.











    $(document).ready(function(){
    $('.slides li').each(function(index) {
    $(this).attr('width', 250);
    });
    });

    My code only changes the

  • width, I want to change img width. Is it possible?
#91256
XaviJr
Participant

I target li because in your way the width of img is undefined:

$(document).ready(function() {
$('.slides li img').each(function(index) {
alert($(this).width());
});
});

But I was able to solve the problem with:

$(document).ready(function(){
$('.slides li').each(function(index) {
$(this).find('img').css('width', 250);
});
});
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.