Saturday, 15 June 2013

javascript - Why is my checkbox not connecting with my jQuery? -



javascript - Why is my checkbox not connecting with my jQuery? -

i don't why check-box beingness clicked doesn't prompt js well. i'll write code , explain little more in depth what's happening.

here's header (in-case i'm linking wrong files):

<head> <link rel='stylesheet' href='reset.css'/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <link rel='stylesheet' href='vector add.css'/> <script src='vector add.js'></script> </head>

here's checkbox itself:

<div id='gridbutton'> <form> <input type="checkbox" id="gridcheck" value="showgrid"> show grid </form> </div>

here's first line of code table (the table big , there's no value in linking code):

<table id="gridtable" style="position:absolute">

here's js:

$(document).ready(function(){ if($('#gridcheck').is(':checked')===true){ $('#gridtable').show('fast'); } else { $('#gridtable').hide('fast'); }; });

essentially have graph , want user able generate grid whenever click "show grid" check-box , go away when check-box isn't selected. reason it's not working. there no errors when bring dev tool it's showing js isn't realizing whether or not buttons beingness clicked. don't know i've been grappling past couple hours , nil seems work. please help out! in advance!

you need bind click event checkbox triggered on every check on , off.

$(document).ready(function(){ $('#gridcheck').on('click', function(){ if ($(this).is(':checked')){ $('#gridtable').show('fast'); } else { $('#gridtable').hide('fast'); } }); });

javascript jquery html dom

No comments:

Post a Comment