Reputation: 32321
http://jsfiddle.net/2pypy87p/6/
When selected the checkbox , Select All , the stocks under the greaterquan div are selected . And when i click on the FetchAll button , how to get all the names in form of an array whoses checkboxes are selected .
please let me know how to do this
This is my code
$(document).ready(function() {
$('#selecctall').click(function(event) {
if(this.checked)
{
$('#greaterquan .mycheckbox').each(function() {
this.checked = true; //select all checkboxes with class "checkbox1"
});
}
else
{
$('#greaterquan .mycheckbox').each(function() {
this.checked = false; //select all checkboxes with class "checkbox1"
});
}
});
$(document).on('click', '.fetchall', function(e)
{
alert('ssssssss');
});
Upvotes: 0
Views: 24
Reputation: 388316
You can use :checked selector and .map() like
$(document).ready(function () {
$('#selecctall').click(function (event) {
$('#greaterquan .mycheckbox').prop('checked', this.checked)
});
$(document).on('click', '.fetchall', function (e) {
var array = $('#greaterquan .mycheckbox:checked').map(function () {
return this.nextSibling.nodeValue;
}).get();
console.log(array)
});
});
Demo: Fiddle
Upvotes: 1