简体   繁体   中英

change img source with attr not working on ios5

I'm trying to change the source of an image and have t fade in when you click in another spot, and it's set up like so

$('.thumbs').bind('click', function() {
  $('#MyT').attr('class', 'wierd');
  $('#MyT').fadeIn(0);
});

it works well when I test it on Chrome, but when I upload it to iPad, it doesn't change the source. What am I doing wrong here?

Changing the class value of the image won't change its src . If you wanted to change its source, you would do something like this:

$(".thumbs").on("click", function(){
  $("#MyT").attr("src", "image2.png").fadeIn("slow");
});

I'm assuming of course there is a <img src="foo.png" id="MyT" /> on your page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM