JavaScript
Article
By Sam Deering

jquery get label text associated with checkbox

By Sam Deering

Simple jQuery code snippet to get label text associated with checkbox.

console.log($('label[for="carHireChk"]').html());
$("label[for='comedyclubs']")
$("label[for=' + this.attr("id") + ']").attr('class', 'error');

See doco for more info: http://api.jquery.com/next-adjacent-Selector/

--ADVERTISEMENT--

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account