显示/隐藏在IE8中不起作用-JQUERY

渡轮夫人

我曾尝试看过其他与我类似的问题,但没有一个对我有帮助。

当用户单击输入时,我需要逐个显示和隐藏多个div。我的代码在IE8以外的所有浏览器中均能正常工作,即IE不会显示任何内容,也就是说div不会显示。请有人可以帮助我解决这个问题吗?

这是我的HTML

<div id="tabbedBox">
                    <form action="" method="">
                        <div class="tabbed" id="selectMe">
                            <input type="radio" target="1" id="pvl" name="radios" value="a" checked>
                            <label class="pvl"  for="pvl">PVL</label>
                            <input type="radio" target="2" id="cvl" name="radios" value="b">
                            <label class="cvl" for="cvl">CVL</label>
                            <input type="radio" target="3" id="industrial" name="radios" value="c">
                            <label class="industrial" for="industrial">Industrial</label>
                            <input type="radio" target="4" id="distributor" name="radios" value="d">
                            <label class="distributor" for="distributor">Distributor</label>
                        </div>





                        <div class="pvlBox tabbedContent" id="div1">
                            <div class="select">
                                <input type="radio" id="installed" name="radios" value="" checked>
                                <label for="installed">Installed</label>
                            </div>
                            <span>Installed</span>
                            <div class="select">
                                <input type="radio" id="retail" name="radios" value="">
                                <label for="retail">Retail</label>
                            </div>
                            <span>Retail</span>
                            <div class="select">
                                <input type="radio" id="service" name="radios" value="">
                                <label for="service">Service Station</label>
                            </div>
                            <span>Service Station</span>
                        </div>

                            <div class="cvlBox tabbedContent" id="div2" style="display:none">
                                CVL CONTENT
                            <div class="select">
                                <input type="radio" id="installed" name="radios" value="" checked>
                                <label for="installed">Installed</label>
                            </div>
                            <span>Installed</span>
                            <div class="select">
                                <input type="radio" id="retail" name="radios" value="">
                                <label for="retail">Retail</label>
                            </div>
                            <span>Retail</span>
                            <div class="select">
                                <input type="radio" id="service" name="radios" value="">
                                <label for="service">Service Station</label>
                            </div>
                            <span>Service Station</span>
                        </div>
                            <div class="industrialBox tabbedContent" id="div3"  style="display:none">
                                INDUSTRIAL CONTENT
                            <div class="select">
                                <input type="radio" id="installed" name="radios" value="" checked>
                                <label for="installed">Installed</label>
                            </div>
                            <span>Installed</span>
                            <div class="select">
                                <input type="radio" id="retail" name="radios" value="">
                                <label for="retail">Retail</label>
                            </div>
                            <span>Retail</span>
                            <div class="select">
                                <input type="radio" id="service" name="radios" value="">
                                <label for="service">Service Station</label>
                            </div>
                            <span>Service Station</span>
                        </div>

                            <div class="distributorBox tabbedContent" id="div4"  style="display:none">
                                DISTRIBUTOR CONTENT
                            <div class="select">
                                <input type="radio" id="installed" name="radios" value="" checked>
                                <label for="installed">Installed</label>
                            </div>
                            <span>Installed</span>
                            <div class="select">
                                <input type="radio" id="retail" name="radios" value="">
                                <label for="retail">Retail</label>
                            </div>
                            <span>Retail</span>
                            <div class="select">
                                <input type="radio" id="service" name="radios" value="">
                                <label for="service">Service Station</label>
                            </div>
                            <span>Service Station</span>
                        </div>

                        <br/>


                    </form>
            </div><!--/end tabbedbox-->

这是jQuery代码:

$('#pvl').click(function() {
        $('div[id^=div]').hide();
        $('#div1').show();

    });
    $('#cvl').click(function() {
        $('div[id^=div]').hide();
        $('#div2').show();
    });

    $('#industrial').click(function() {
        $('div[id^=div]').hide();
        $('#div3').show();
    });

    $('#distributor').click(function() {
        $('div[id^=div]').hide();
        $('#div4').show();
    });

});
埃斯科

我添加了一些标记来简化脚本。还将click事件更改为change-event:

小提琴

脚本:

$(function () {
    $(".js-change").on("change", function () {
        $(".Box").hide();
        $("." + $(this).data("show-content")).show();
    });
});

HTML(添加到单选按钮的类和数据属性):

<div id="tabbedBox">
    <form action="" method="">
        <div class="tabbed" id="selectMe">
            <input type="radio" target="1" id="pvl" name="radios" value="a" 
                  class="js-change" data-show-content="pvlBox" checked>
            <label class="pvl" for="pvl">PVL</label>
            <input type="radio" target="2" id="cvl" name="radios" value="b" 
                  class="js-change" data-show-content="cvlBox">
            <label class="cvl" for="cvl">CVL</label>
            <input type="radio" target="3" id="industrial" name="radios" value="c"
                  class="js-change" data-show-content="industrialBox">
            <label class="industrial" for="industrial">Industrial</label>
            <input type="radio" target="4" id="distributor" name="radios" value="d"
                  class="js-change" data-show-content="distributorBox">
            <label class="distributor" for="distributor">Distributor</label>
        </div>
        <div class="Box pvlBox tabbedContent">
            <div class="select">
                <input type="radio" id="installed" name="radios" value="" checked>
                <label for="installed">Installed</label>
            </div> <span>Installed</span>

            <div class="select">
                <input type="radio" id="retail" name="radios" value="">
                <label for="retail">Retail</label>
            </div> <span>Retail</span>

            <div class="select">
                <input type="radio" id="service" name="radios" value="">
                <label for="service">Service Station</label>
            </div> <span>Service Station</span>

        </div>
        <div class="Box cvlBox tabbedContent" style="display:none">CVL CONTENT
            <div class="select">
                <input type="radio" id="installed" name="radios" value="" checked>
                <label for="installed">Installed</label>
            </div> <span>Installed</span>

            <div class="select">
                <input type="radio" id="retail" name="radios" value="">
                <label for="retail">Retail</label>
            </div> <span>Retail</span>

            <div class="select">
                <input type="radio" id="service" name="radios" value="">
                <label for="service">Service Station</label>
            </div> <span>Service Station</span>

        </div>
        <div class="Box industrialBox tabbedContent" style="display:none">INDUSTRIAL CONTENT
            <div class="select">
                <input type="radio" id="installed" name="radios" value="" checked>
                <label for="installed">Installed</label>
            </div> <span>Installed</span>

            <div class="select">
                <input type="radio" id="retail" name="radios" value="">
                <label for="retail">Retail</label>
            </div> <span>Retail</span>

            <div class="select">
                <input type="radio" id="service" name="radios" value="">
                <label for="service">Service Station</label>
            </div> <span>Service Station</span>

        </div>
        <div class="Box distributorBox tabbedContent" id="div4" style="display:none">DISTRIBUTOR CONTENT
            <div class="select">
                <input type="radio" id="installed" name="radios" value="" checked>
                <label for="installed">Installed</label>
            </div> <span>Installed</span>

            <div class="select">
                <input type="radio" id="retail" name="radios" value="">
                <label for="retail">Retail</label>
            </div> <span>Retail</span>

            <div class="select">
                <input type="radio" id="service" name="radios" value="">
                <label for="service">Service Station</label>
            </div> <span>Service Station</span>

        </div>
        <br/>
    </form>
</div>
<!--/end tabbedbox-->

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

click()jQuery在IE8中不起作用

来自分类Dev

jQuery CSS转换在IE8中不起作用?

来自分类Dev

jQuery 显示/隐藏在 for 循环中不起作用

来自分类Dev

显示html表的隐藏在javascript(IE8)中不起作用

来自分类Dev

jQuery的CSS方法中的-=运算符在IE8中不起作用

来自分类Dev

多属性jQuery选择器在IE8中不起作用

来自分类Dev

堆叠jQuery CSS声明在IE8中不起作用

来自分类Dev

在ie8 / 9中的jQuery ajax调用不起作用

来自分类Dev

使用jQuery创建的DOM元素在IE8中不起作用

来自分类Dev

后代jQuery选择器在IE8中不起作用

来自分类Dev

jQuery隐藏选项在IE 11中不起作用

来自分类Dev

IE8和Jquery .post ajax调用不起作用

来自分类Dev

jQuery显示/隐藏DIV不起作用

来自分类Dev

jQuery 显示/隐藏不起作用

来自分类Dev

Kendo UI Jquery Grid 在 IE 8 中不起作用

来自分类Dev

jQuery选择器来计算空文本框的数量在IE9 / IE8中不起作用

来自分类Dev

jQuery脚本在IE中不起作用

来自分类Dev

无法显示/隐藏在jQuery中

来自分类Dev

显示/隐藏div jQuery在固定位置不起作用

来自分类Dev

jQuery复选框显示隐藏div不起作用

来自分类Dev

jQuery显示隐藏部分不起作用-包括JSfiddle

来自分类Dev

jQuery在If / Else语句中隐藏/显示不起作用

来自分类Dev

jQuery显示隐藏多个Div不起作用

来自分类Dev

使用jQuery显示和隐藏div在我的代码中不起作用

来自分类Dev

jQuery funciton来显示消息在ie10中不起作用,但在chrome中起作用

来自分类Dev

jQuery复选框更改功能在IE 8中不起作用

来自分类Dev

jQuery单击事件在IE11 Windows8中不起作用

来自分类Dev

隐藏功能在jQuery Mobile中似乎不起作用

来自分类Dev

jQuery隐藏功能在Firefox中不起作用

Related 相关文章

热门标签

归档