Morgan Ng Morgan Ng - 2 months ago 14
HTML Question

Onclick Display Block to None and None to Block in jQUERY

Simple question :

how to set other to display block only selected onlick on particular div will display block the rest will display:none.

jQUERY :

$('.menu_jyclass').click(function(){
var vr=$(this).attr('vr')
$(".table_main").hide()
$("#main_"+vr).show();
$('.menu_jyclass').removeClass('cur');
$(this).addClass('cur')
});

$("#hn").click(function () {
$("#zhifubaoDiv").css("display","block")
// $("#").show();
});

$("#wx").click(function () {
$("#wangyincunkuan2Div").css("display","block")
// $("#").show();
});


HTML

<a class="menu_jyclass" id="hn" vr="hn">微信支付</a>
<a class="menu_jyclass cur" id="wx" vr="wx">在线支付</a>

<div id="zhifubaoDiv" class="ListItemSub clearfix" style="display: none;">
<div id="wangyincunkuan2Div" class="ListItemSub clearfix" style="display:none;">

Answer

Try this:

Javascript:

$("#hn").click(function () {
        $("#wangyincunkuan2Div").css("display","none")
        $("#zhifubaoDiv").css("display","block")
        // $("#").show();   
    });

    $("#wx").click(function () {
        $("#wangyincunkuan2Div").css("display","block")
        $("#zhifubaoDiv").css("display","none")
        // $("#").show();   
    });

Fiddle Here: https://jsfiddle.net/c8czc69e/

Comments