Adding/Removing border to TR using JQuery -
please see following jsfiddle: jsfiddle link
my jquery:
$('.tr1').addclass('addborder'); $('.tr2').removeclass('removeborder'); $('#bname').click(function() { $('.tr1').addclass('addborder'); $('.tr2').addclass('removeborder'); }); $('#bspecialty').click(function() { $('.tr2').addclass('addborder'); $('.tr1').addclass('removeborder'); });
it suppose make name row have double blue border , based on user selection radio button should make row have blue border , remove border row not selected. it's not working reason.
i tried toggleclass();
removes existing class, won't work user should able click on same radio button multiple times , class should not change. should change if other radio button clicked.
you should add border table cell not row. don't need add 2 different class.. instead can addclass
adds border , removeclass
on other. see demo: http://jsfiddle.net/xz5eg/
$(function () { var $rowname = $('.tr1 td'); var $rowspeciality = $('.tr2 td'); $rowname.addclass('addborder'); $rowspeciality.removeclass('removeborder'); $('#bname').click(function() { $rowname.addclass('addborder'); $rowspeciality.removeclass('addborder'); }); $('#bspecialty').click(function() { $rowspeciality.addclass('addborder'); $rowname.removeclass('addborder'); }); });
Comments
Post a Comment