javascript - onclick doesn't work properly with bootstrap -


i tried use onclick event bootstrap radio-buttons names , attributes how didn't go well.

some of radio-buttons triggered event didn't name or class ("undefined") , didn't respond @ all.

<div class="thecontainer">       <input type="radio" class="myclass" name="options" id="option1" onclick="updateodid()" autocomplete="off" > radio 1   <input type="radio" class="myclass" name="options" id="option2" onclick="updateodid()" autocomplete="off"> radio 2   <input type="radio" class="myclass" name="options" id="option3" onclick="updateodid()" autocomplete="off"> radio 3   <input type="hidden" class="findme" value="found me!">   <div class="btn-group" data-toggle="buttons">     <label class="btn btn-primary active">       <input type="radio" class="myclass" name="options" id="option1"       onclick="updateodid()" autocomplete="off" > radio 1     </label>     <label class="btn btn-primary">       <input type="radio" class="myclass" name="options" id="option2" onclick="updateodid()" autocomplete="off"> radio 2     </label>     <label class="btn btn-primary">       <input type="radio" class="myclass" name="options" id="option3" onclick="updateodid()" autocomplete="off"> radio 3     </label>   </div>  </div> 

jsfiddle.net/2sc8mc7l/6/

thanks!

it's not working because have mixed javascript , jquery in wrong way.

please check updated snippet : https://jsfiddle.net/2sc8mc7l/12/ onclick function should below :

$(".myclass").on('click',function(){   radiobuttonclick($(this)); });  $("label.btn-primary").on('click',function(){   radiobuttonclick($(this).find('.myclass')); });  function radiobuttonclick(_this){   alert("i'm in!")   alert (_this.attr('name'));   alert (_this.attr('class'));   alert (_this.closest(".thecontainer").find(".findme").val()); } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -