Jump to content

Toggle a div using radio buttons


vivekam8

Recommended Posts

I am very new to jquery and ajax. While googling (i wonder if "googling" is a dictionary word!!) for some code which enables to toggle between two divs using radio buttons, I stumbled upon this code. It is not working but I feel it is very close to being correct!! Can someone help me to correct this?

 

Thanks in advance

Your fan!

<html>
<head>

<script type="text/javascript">

$(function() {
    $("[name=toggler]").click(function(){
            $('.toHide').hide();
            $("#blk-"+$(this).val()).show('slow');
    });
});

</script>

</head>

<body>

<label><input id="rdb1" type="radio" name="toggler" value="1" />Money</label>
<label><input id="rdb2" type="radio" name="toggler" value="2" />Interest</label>

<div id="blk-1" class="toHide" style="display:none">
    money
</div>
<div id="blk-2" class="toHide" style="display:none">
    interest
</div>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/261680-toggle-a-div-using-radio-buttons/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.