jQuery IE 问题

发布于 2024-12-01 22:55:36 字数 3576 浏览 0 评论 0原文

可能的重复:
jQuery 浏览器兼容性 (IE)

我最初会发布一些代码片段(如果您要求的话,我也会发布一些代码片段) ),但我认为如果您点击此链接并直接查看我的问题,这个问题会更容易识别。而且,代码片段可能会变得相当冗长。

链接:http://www.thesportinghub.com/lms/make-my-picks< /a>

如果您在 Google Chrome、IE9、Firefox 5.0+ 或 Safari 中打开此页面,并且稍微单击一下,您就会注意到此页面的功能。正如我在这些浏览器中所制定的那样,它工作正常且完美。

我面临的问题是 jQuery 兼容性。当您选择一个单选按钮(在上述浏览器之一中)时,它将划掉相应的团队,并在接下来的几周内禁用该团队的其余单选按钮。您应该会看到它在“工作”浏览器中的两个位置被划掉。

然而,跳转到 IE7 和 IE8,你会发现情况并非如此。我上下查找了代码中的基本语法错误,并无休止地搜索网络来解决这个问题。我非常感谢任何人对此的帮助。

我愿意提供更多信息、代码片段,并积极参与解决我遇到的这个问题。

更新代码:

<script type="text/javascript">
$(document).ready(function(){

$('.radio:checked').addClass("selected");
$('.pickbox').text($('.radio:checked').val());

var selected_week = $('#weekselect').val();

$('table.weekbox').hide();
$('table#weekbox' + selected_week).show();
$('span.selection.text').html('<br/>My Week ' + selected_week + ' Selection:');


    $('input.radio').change(function () {
        $('.teambox').find('span.strike').removeClass('strike');
        var selected = $(this).val();
        var us_selected = selected.replace(/ /g, "");

        $('.radio:not(:checked)').removeClass('selected');
        $('.radio:not(:checked)').next('span').css('color','');
        $('.radio:not(:checked)').removeAttr('disabled');
        $('.radio:checked').addClass('selected');
        $('.pickbox').text($(this).val());
        $('.pickbox').css('border','3px dashed #88cc33');
        //$('.pickbox').text($('.teambox').find('span.' + us_selected).text());
        $('.teambox').find('span.' + us_selected).addClass('strike');

    $('.selected').each(function () {
    var selected_team = $(this).val();
    var x_selected_team = selected_team.replace(/ /g, "");
    $('.teambox').find('span.' + x_selected_team).text(selected_team).addClass('strike');
    $('table.weekbox').find('td input[value="' + selected_team + '"]').attr('disabled', 'disabled');
    $('.selected').next('span').css('color','#88cc33');
    });
        });


  $('#weekselect').change(function () {
    var selected_week = $('#weekselect').val();

    if ($('input[name="Week' + selected_week + '"]').is(':not(:checked)')) {
        $('table.weekbox').hide();
        $('table#weekbox' + selected_week).show();
        $('span.selection.text').html('<br/>My Week ' + selected_week + ' Selection:');
    $('.pickbox').css('border','1px dashed #FFFFFF');
    $('.pickbox').text('');
    }

        $('table.weekbox').hide();
        $('table#weekbox' + selected_week).show();
        $('span.selection.text').html('<br/>My Week ' + selected_week + ' Selection:');
        $('input:not(:checked)').next('span').removeClass('strike');
        $('input[disabled]:not(:checked)').next('span').addClass('strike');

    $('.pickbox').text($('input.radio[name="Week' + selected_week + '"].selected').val());

    if ($('.pickbox').text() != "") {
        $('.pickbox').css('border','3px dashed #88cc33');
    }

    $('.selected').each(function () {
    var selected_team = $(this).val();
    var x_selected_team = selected_team.replace(/ /g, "");
    $('.teambox').find('span.' + x_selected_team).text(selected_team).addClass('strike');
    });

});
});
</script>

这是我的 jQuery 脚本...有人提到我的 IE 问题是因为我的单选按钮没有从 .change 函数中读取,并且需要 .click .. 。

Possible Duplicate:
jQuery Browser Compatability (IE)

I would initially post some code snippets (and will if you request it), but I think this problem would be easier to identify if you follow this link and check out my problem firsthand. And, the code snippets could get rather lengthy.

Link: http://www.thesportinghub.com/lms/make-my-picks

If you open up this page in Google Chrome, IE9, Firefox 5.0+, or Safari, and if you click around a bit, you will notice how this page is INTENDED to function. It is working PROPERLY and PERFECTLY as I have drawn up in these browsers.

The problem I am facing is with jQuery compatability. When you select a radio button (while in one of the aforementioned browsers), it will cross out that respective team and disable the remaining radio buttons for that team throughout the rest of the weeks. You should see it cross out in two places in the "working" browsers.

However, jump to IE7 and IE8 and you will notice the same is not the case. I have looked up and down my code for basic syntax errors and have searched the web endlessly to solve this. I would much appreciate anyone's assistance with this.

I am willing to provide more information, code snippets, and be actively involved in trying to solve this issue I am having.

UPDATE WITH CODE:

<script type="text/javascript">
$(document).ready(function(){

$('.radio:checked').addClass("selected");
$('.pickbox').text($('.radio:checked').val());

var selected_week = $('#weekselect').val();

$('table.weekbox').hide();
$('table#weekbox' + selected_week).show();
$('span.selection.text').html('<br/>My Week ' + selected_week + ' Selection:');


    $('input.radio').change(function () {
        $('.teambox').find('span.strike').removeClass('strike');
        var selected = $(this).val();
        var us_selected = selected.replace(/ /g, "");

        $('.radio:not(:checked)').removeClass('selected');
        $('.radio:not(:checked)').next('span').css('color','');
        $('.radio:not(:checked)').removeAttr('disabled');
        $('.radio:checked').addClass('selected');
        $('.pickbox').text($(this).val());
        $('.pickbox').css('border','3px dashed #88cc33');
        //$('.pickbox').text($('.teambox').find('span.' + us_selected).text());
        $('.teambox').find('span.' + us_selected).addClass('strike');

    $('.selected').each(function () {
    var selected_team = $(this).val();
    var x_selected_team = selected_team.replace(/ /g, "");
    $('.teambox').find('span.' + x_selected_team).text(selected_team).addClass('strike');
    $('table.weekbox').find('td input[value="' + selected_team + '"]').attr('disabled', 'disabled');
    $('.selected').next('span').css('color','#88cc33');
    });
        });


  $('#weekselect').change(function () {
    var selected_week = $('#weekselect').val();

    if ($('input[name="Week' + selected_week + '"]').is(':not(:checked)')) {
        $('table.weekbox').hide();
        $('table#weekbox' + selected_week).show();
        $('span.selection.text').html('<br/>My Week ' + selected_week + ' Selection:');
    $('.pickbox').css('border','1px dashed #FFFFFF');
    $('.pickbox').text('');
    }

        $('table.weekbox').hide();
        $('table#weekbox' + selected_week).show();
        $('span.selection.text').html('<br/>My Week ' + selected_week + ' Selection:');
        $('input:not(:checked)').next('span').removeClass('strike');
        $('input[disabled]:not(:checked)').next('span').addClass('strike');

    $('.pickbox').text($('input.radio[name="Week' + selected_week + '"].selected').val());

    if ($('.pickbox').text() != "") {
        $('.pickbox').css('border','3px dashed #88cc33');
    }

    $('.selected').each(function () {
    var selected_team = $(this).val();
    var x_selected_team = selected_team.replace(/ /g, "");
    $('.teambox').find('span.' + x_selected_team).text(selected_team).addClass('strike');
    });

});
});
</script>

There is my jQuery script... Someone has mentioned my IE problems are because my radio buttons are not being read from the .change function, and that it needed to be .click...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末染殇 2024-12-08 22:55:36

您的问题是您在单选按钮上使用 change 而不是 click。 IE 需要在触发更改事件之前使单选按钮模糊。另外,在元素 ID 中使用空格时要非常小心。

Your problem is that you are using change on the radio buttons instead of click. IE needs the radio buttons to blur before firing the change event. Also, be very careful using spaces in your element IDs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文