is :checked not working while using Jquery 1.7 -


look @ simple code


html

<input type="checkbox" id="check" >&nbsp;<span id="rm">remember me</span> <span id="ok">okay!</span> 

css

#ok{ position:absolute; font:italic bold 14px century; color:green; margin-left:3px; margin-top:2px; display:inline-block; opacity:0; } 

jquery

if($('#check').is(":checked"))     {     $("#ok").css("opacity",1);     } 

http://jsfiddle.net/milanshah93/4hf9t/

it not working when check box.

your checkbox not checked on page load. although can -

$("#check").on('change', function () {     if ($(this).is(":checked")) {         $("#ok").css("opacity", 1);     }     else{      $("#ok").css("opacity", 0);     } }); 

demo


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -