Have a table column I\'m trying to expand and hide:
jQuery seems to hide the td elements when I select it by class but not by element\'s name.
You could get the array of elements by name the old fashioned way and pass that array to jQuery.
function toggleByName() {
var arrChkBox = document.getElementsByName("chName");
$(arrChkBox).toggle();
}
sandBox
note: the only time you would have a reason to use the "name" attribute should be for checkbox or radio inputs.
Or you could just add another class to the elements for selection.(This is what I would do)
function toggleByClass(bolShow) {
if (bolShow) {
$(".rowToToggle").show();
} else {
$(".rowToToggle").hide();
}
}
sandBox
data1
data2
data1
data2
data1
data2