JQuery add 2 checkbox one label

3142
2
11-18-2015 10:31 AM
FaisalBukhari
New Contributor II

<form>

<input  id='Ckh_0' name="Ckh_0" type='checkbox'  checked=SetLayerDefaultVisible(0)  data-iconpos=right />

<label  for='Ckh_0'>port</label></td><td colspan='1' >

</form>

0 Kudos
2 Replies
AlexanderMena
New Contributor II

Hi, here a idea:

<html>

<form>

<input  id='Ckh_0' name="Ckh_0" type='checkbox'  checked=SetLayerDefaultVisible(0)  data-iconpos=right/>

    <input  id='Ckh_1' name="Ckh_0" type='checkbox'  checked=SetLayerDefaultVisible(0)  data-iconpos=right />

<label  for='Ckh_0'>port</label></td><td colspan='1' >

</form>

</html>

<script>

$(document).ready(function() {

    $('#Ckh_0').change(function() {

        var estado = $('#Ckh_0').prop('checked');

        $('#Ckh_1').prop('checked', estado);

    });

    $('#Ckh_1').change(function() {

        var estado = $('#Ckh_1').prop('checked');

        $('#Ckh_0').prop('checked', estado);

    });

});

</script>

Edit fiddle - JSFiddle

Sorry by the code in the editor, example complete is in fiddle.

0 Kudos
FaisalBukhari
New Contributor II

Thanks Alex

My above  code generate two Checkboxes and one label ,  but i need one Checkbox with Label ?

0 Kudos