jquery适用于chrome和firefox,而不是IE

时间:2011-03-08 05:47:09

标签: javascript jquery

这在IE中不起作用......任何想法?点击它只是加载新页面

<script type="application/javascript" src="lib/js/photos_fb_manage.js"></script>    
<ul class="photoList">
    <li id="k877575065600">
    <a href="/mem_fb_addphotos.php?addphoto.php?fbpid=877575065600&album=837932838940" id="877575065600" class="fbpm">
    <img src="http://photos-f.ak.fbcdn.net/hphotos-ak-snc4/155193_877575065600_22912405_47840445_3804175_s.jpg" />
    <span>Add To Profile</span>
    </a>
    </li>
    </ul>

    $(document).ready(function()
    {
        $('.fbpm').click(function(e)
        {
            fbpid = $(this).attr('id');
            $(this).find('span').text('PHOTO ADDED');
            $(this).parent('li').addClass('selected');
            $('#addedPhotos').show();
            $('<img src="images/loading.gif" id="loadimg" />').appendTo('#addedPhotos');

            $.ajax({
               type: "POST",
               url: "php/ajax/photos_fb_manage.php",
               data: "fbp="+ fbpid +"",
               success: function(msg){
                $('#loadimg').remove();
                $('<img src="'+ msg +'" />').appendTo('#addedPhotos');
               }
             });

            e.preventDefault();

        });
    });

3 个答案:

答案 0 :(得分:1)

将代码放在<script>标记内。

<script type="text/javascript">

$(document).ready(function()
    {
        $('.fbpm').click(function(e)
        {
            fbpid = $(this).attr('id');
            $(this).find('span').text('PHOTO ADDED');
            $(this).parent('li').addClass('selected');
            $('#addedPhotos').show();
            $('<img src="images/loading.gif" id="loadimg" />').appendTo('#addedPhotos');

            $.ajax({
               type: "POST",
               url: "php/ajax/photos_fb_manage.php",
               data: "fbp="+ fbpid +"",
               success: function(msg){
                $('#loadimg').remove();
                $('<img src="'+ msg +'" />').appendTo('#addedPhotos');
               }
             });

            e.preventDefault();

        });
    });

</script>

我认为firefox / chrome悄悄地去了“哦,你忘记了脚本标签。我会为你解决这个问题”

答案 1 :(得分:0)

将此e.preventDefault();移到此处

$('.fbpm').click(function(e)
    {
e.preventDefault();

删除此

event.returnValue = false;

答案 2 :(得分:0)

从应用程序/ javascript到text / javascript切换javascript类型并修复它