$('img#'+obj).parent('li').append('<div class=bar></div>');
$('.bar').show();
ie下有效,chrome下无效,怎么办?

解决方案 »

  1.   

    用jq吗?
    第一行添加了就自然会显示, 第二行还要显示干嘛?
    chrome调试下看看是什么错误?
      

  2.   

    $('img#'+obj)
    $('#img'+obj)  ???
      

  3.   


    或者 加个setTimeout试试 setTimeout(function(){$('.bar').show();
    },0)
      

  4.   

    问个问题最好把demo贴全,很多情况和上下文是有关系,再说也不方便调试和重现问题。测试了,没发现什么问题,一切正常。
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    </head>
    <body>
    <li>
    <img id="image" src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif" />
    </li>
    <script>
    var obj = "image";
    $('img#'+obj).parent('li').append('<div class=bar>有什么不对?</div>');
    $('.bar').show();
    </script>
    </body>
    </html>
      

  5.   

    这样的代码无法解释
    append方法没有兼容性问题~
      

  6.   

    for(i=0; i<(array.length-1); i++){
    id = array[i].substr(0,10);
    $('div#photo ul').append('<li><img class=photo id=' + id + ' src=photo/'+dir+'/'+array[i]+' width=154 /></li>');
    }
    var getObj = $('img.photo');
    getObj.each(function(id) {
    var obj = this.id;
    $('img#'+obj).mouseover(function(){
    $('.bar').remove();
    $('img#'+obj).parent('li').append('<div class=bar></div>');
    $('.bar').show();

    $('.bar').click(function(){
    $('#act')[0].value = 'photodel';
    $('#photoname')[0].value = $('img#'+obj)[0].src.slice(-14);
    $('img#'+obj).parent('li').remove();
    $('#act')[0].value = 'photodel';
    $('#photopost').ajaxSubmit({
    target: 'div#notice',
    url: 'post.php',
    success: function(msg) {
    if(msg!="OK"){
    alert(msg);
    }
    }
    });
    });
    });
    });
    这是代码