Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

button group get value

<div class="btn-group" data-toggle="buttons-radio">
        <button class="btn">1</button>
        <button class="btn">2</button>
        <button class="btn">3</button>
        <button class="btn">4</button>
</div>




var num = null;
var ele = document.querySelectorAll(".btn-group > button.btn");
for(var i=0; i<ele.length; i++){
    ele[i].addEventListener("click", function(){
        num = +this.innerHTML;
        alert("Value is " + num);
    });
}
Or jQuery:

var num = null;
$(".btn-group > button.btn").on("click", function(){
    num = +this.innerHTML;
    alert("Value is " + num);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native textinput not show cursor 
Javascript :: angular date input value 
Javascript :: eslint linebreak style 
Javascript :: react navigation transparent header 
Javascript :: javascript onclick event listener 
Javascript :: javascript group by sum array reduce 
Javascript :: jquery change span tag text 
Javascript :: how to prepare key in object dyamically javascript 
Javascript :: remove element from array javascript 
Javascript :: es6 get text between quotes and double quotes 
Javascript :: sinha crud template 
Javascript :: opal find element 
Javascript :: react native code push app center key 
Javascript :: how to disable all buttons in javascript 
Javascript :: react conditional classname 
Javascript :: react npm build 
Javascript :: how to make chart js from zero 
Javascript :: nodejs powershell process env 
Javascript :: js find key by value in object 
Javascript :: how to give a label padding through jquery 
Javascript :: pipefy api card search field 
Javascript :: js take last item in array 
Javascript :: react-dom.development.js:86 Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. 
Javascript :: javascript match number 
Javascript :: get lat long from zip code in google places api 
Javascript :: jquery scroll to div callback 
Javascript :: js remove extension from filename 
Javascript :: set interval react 
Javascript :: regex check is valid ip 
Javascript :: query params in next js 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =