Sunday, May 21, 2017

Checked checkbox value in multiple chekcbox in javascript

Tags



 Here a quick example.

 <input class='try' type="checkbox" name="device" id="1_2" value="1" />
 <input class='try' type="checkbox" name="device" id="10_4" value="2" />
 <input class='try' type="checkbox" name="device" id="5_6" value="3" />
 <input class='try' type="checkbox" name="device" id="4_0" value="4" />
 <input class='try' type="checkbox" name="device" id="8_9" value="5" />
 <input class='try' type="checkbox" name="device" id="3_4" value="6" />

$('.try').click(function() {
    var value = $(this).val();
   var idd= $(this).attr('id');
   var explode = idd.split('_');
    alert('Value before:' +value + ' - Value after:' + value);
});

Example here 

Thanks for watching my blog. Do follow me on google+ or like my facebook page for more! :)
Obstrum Facebook Page


EmoticonEmoticon

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:o
:>)
(o)
:p
:-?
(p)
:-s
8-)
:-t
:-b
b-(
(y)
x-)
(h)