javascript - Jquery radio button doesnt register click -
i have following 2 div block:
<div class="span9" id="lejer"> <div class="span9" id="udejer"> note in html have alot of things within them sake of keeping short not post of it.
at top of document have following radio buttons:
<div class="controls"> <label class="radio inline"> <input id="optionsradios1" type="radio" name="optionsradios" value="option1" checked="" id="select_lejer"> jeg er lejer </label> <label class="radio inline"> <input id="optionsradios1" type="radio" name="optionsradios" value="option1" checked="" id="select_udlejer"> <p style="padding-left:1em"> jeg er udlejer</p> </label> </div> now toggle between visibilty of 2 div tags have created following jquery:
jquery(document).ready(function(){ $('#select_lejer').click(function(){ $('#udlejer').hide(); $('#lejer').toggle( "slow", function() { // animation complete. }); }); $('#select_udlejer').click(function(){ $('#lejer').hide(); $('#udlejer').toggle( "slow", function() { // animation complete. }); }); }); when page loaded 1 of radio buttons checked , 1 of divs correctly hidden however when click radio buttons nothing happens.
can tell me doing wrong?
id must unique in html, using optionsradios1 radiobuttons
your code
<input id="optionsradios1" type="radio" name="optionsradios" value="option1" checked="" id="select_lejer"> <input id="optionsradios1" type="radio" name="optionsradios" value="option1" checked="" id="select_udlejer"> remove id="optionsradios1" above code.
also provide id twice radio elements
id="optionsradios1",id="select_lejer"id="optionsradios1",id="select_udlejer"
additionaly, use change event instead of click
Comments
Post a Comment