jquery - How to negate if statement for type="radio" input in javascript -


i'm new in javascript world , know how use if statement. when tried negate if statement of radio button if checked, it's not working. code.

<div class="form-group ">  <label class="form-control-static">waiting location</label>  <div class="radio">   <label><input id="radio_btn" type="radio"> location 1 </label>   </div>  </div>      <script>     if (!(document.getelementbyid('radio_btn').checked)) {              alert('this pop out.');          } </script> 

i'm getting error message of "typeerror: document.getelementbyid(...) null"

thanks in advance!

your code works, have error in html itself, know comments.

i created fiddle test it: http://jsfiddle.net/qks8jek1/

<form> <input type="radio" id="radio_btn" name="sex" value="male">male</input> <br/> <input type="radio" id="radio_btn2" name="sex" value="female" checked>female</input> </form> 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -