Showing posts with label how to get text of selected checkbox jQuery. Show all posts
Showing posts with label how to get text of selected checkbox jQuery. Show all posts

Monday, 21 September 2015

How to get checkbox label text jquery


How to get checkbox label text jquery

Check the below example and you get the script how to get label of checkbox in jQuery

<html>
<body>
    <ul>
        <li>
            <input type="checkbox" name="mouse" value="1" id="mouse"  /><label for="mouse">Mouse</label>
            </li>
            <li>
            <input type="checkbox" name="keyboard" value="1" id="keyboard"  /><label for="mouse">Keyboard</label>
            </li>
            <li>
            <input type="checkbox" name="monitor" value="1" id="monitor"  /><label for="mouse">Monitor</label>
            </li>
        </ul>
    </body>
</html>

<script type="text/javascript">
 var label = jQuery('label[for=' + jQuery(this).attr('id') + ']').html();
 alert(label);
</script>