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);
});
Also in JavaScript:
- electron iframe require is not defined
- js get date in ms
- javascript get hour from date
- convert excel file to json using node js
- javascript data em portugues
- javascript date
- go to next route vuejs
- js domtokenlist to array
- get first element of array javascript
- how to use the match function in javascript for regex
- downgrade angular version in project
- first element of array js
- how to import jquery in js file
- javascript vérifier si une chaine de carctère commence par une majuscule
- Javascript get text input value
- how to add functionality inside js object
- w3schools ajax
- laravel csrf token ajax post
- foreach key value javascript
- how to redirect to another page in javascript on submit type
- react hook form submit outside form
- node js post multipart/form-data
- react native touchableopacity disable
- tobe a number jest