Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
XML
<script type="text/javascript">
    $(document).ready(function() {


       if($("#image").is(":checked"))
       {
           alert('yeas');
       }

    });

</script>




XML
<div class="form-group">

    <input type="radio" name="type" value="image" id="image" />
    <label for="image">image</label>
    <input type="radio" name="type" value="code" id="code"/>
    <label for="code">code</label><br />
</div>




not working what's wrong in my code
Posted
Comments
Kornfeld Eliyahu Peter 24-Feb-14 9:06am    
You check your radio button on page load - who told you it's checked?!
TheSniper105 24-Feb-14 9:23am    
what i want is disable some inputs in page till user check the corresponding radio box

Try this...
HTML
<script type="text/javascript">
  $(document).ready(function() {
    $("#image").change(
      function(){
        if ($(this).is(':checked')) {
            // do what you want here
        }
    });
  });
</script>


Yep,Your one is working.

Live DEMO : JSFiddle
 
Share this answer
 
v2
Comments
Sampath Lokuge 24-Feb-14 9:43am    
+5 :)
Kornfeld Eliyahu Peter 24-Feb-14 9:46am    
That JSFiddle is a good idea - I will use it with your permission...
Sampath Lokuge 24-Feb-14 9:49am    
Yep,It's a great idea.Use it.Permission granted. :)
TheSniper105 24-Feb-14 9:48am    
by the way how to empty textarea value i use
$("#code_txt").removeAttr('value')
but doesn't work
Kornfeld Eliyahu Peter 24-Feb-14 9:52am    
$("#code_txt").value = '';
C#
$(document).ready(function(){
   $("input").on( "click", function() {
       if($("#image").is(":checked"))
       {
           alert('yeas');
       }

   });
});
</script>
 
Share this answer
 
Please have a look on the bellow link :
:checked Selector[^]
Check checkbox checked property using jQuery[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900