用单选框十字框控制div

发布于 2024-11-07 19:15:01 字数 631 浏览 2 评论 0原文

编辑:它的工作问题是名称我传递了错误的名称(空格>_<)

我有4个div,它们在不同的框架中与我的单选框具有相同的ID,当单击单选框时我希望所有 div 消失(淡出)并且与当前单选框具有相同 id 的 div 出现(淡入)其与 $("input[type=radio]") 一起使用 但是当使用 $("input[type=radio][name=zone1_1]") 时它不起作用

verif_check(id_check)//id_check is id of my the radiobox i clicked in
{ 
   $(document).ready(function(){

        $("input[type=radio][name=zone1_1]").each(function(){
            var id=$(this).attr("id"); 
            $(parent.droite.document).contents().find(id).fadeOut(); 
        });

        $(parent.droite.document).contents().find("#"+id_check).fadeIn();
    });
}

edit:it worked problem was with name i passed wrong name(a space >_<)

i have 4 div that have same id as my radio box both in diferent frame, when clicking on a radio box i want all div disapear (fadeOut) and the div with same id of my current radio box appear(fadeIn) its working with $("input[type=radio]")
but when using $("input[type=radio][name=zone1_1]") it dont work

verif_check(id_check)//id_check is id of my the radiobox i clicked in
{ 
   $(document).ready(function(){

        $("input[type=radio][name=zone1_1]").each(function(){
            var id=$(this).attr("id"); 
            $(parent.droite.document).contents().find(id).fadeOut(); 
        });

        $(parent.droite.document).contents().find("#"+id_check).fadeIn();
    });
}

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

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

发布评论

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

评论(1

泅渡 2024-11-14 19:15:01

ID 应该是唯一的。即任何两个元素都不应该具有相同的 ID。如果您想选择多个元素,请使用类名。

您的代码可能不是 foring,因为您使用 ID 调用 find(),而不是 #id。以下内容将在一定程度上纠正您的问题:

$(parent.droite.document).contents().find('#'+id).fadeOut(); 

我也对 verif_check(id_check) 包装器感到困惑。我会删除这个。

IDs shoud be unique. I.e. no two elements should have the same ID. If you want to select multiple elements use the classname instead.

You code may not be foring because you are calling find() with the ID, not #id. The following will go some way to rectifying your problem:

$(parent.droite.document).contents().find('#'+id).fadeOut(); 

I'm also puzzled by the verif_check(id_check) wrapper. I would remove this.

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