Jquery attr('src') undefined in IE 8 (works in FF)

前端 未结 7 1651
广开言路
广开言路 2021-01-18 07:22

This has gotten so far,that I will sum up what we found out:

  • Inside the event handler the attribute src cannot be read in IE8 (FF works fine), neither with

7条回答
  •  滥情空心
    2021-01-18 07:56

    Try to make a delay:

    jQuery(document).ready(function() {
    
      setTimeout(function () {
    
        jQuery('.blogentry').each(function(){
          // your code...
        });
    
      }, 100); // if doesn't work, try to set a higher value
    
    });
    

    UPDATE

    Hope, this code will work.

    $('.blogentry img').each(function(){
      alert( $(this).attr('src') );
    });
    

    UPDATE

    I'm not sure, but maybe IE can't read classes with uppercase first letter... Try to change ".Image_center" to ".image_center"

    UPDATE

    Check your code again. You definitely have some error. Try this jsfiddle in IE8, attr('src') is showed correctly. http://jsfiddle.net/qzFU8/

提交回复
热议问题