jquery - Set a parents parent css using javascript/ knockout -


i've got checkboxes within table , want css of parent dependent upon whether it's checkbox checked or not. can't seem work , hoping point me in right direction.

at moment, i've got setcss() function on checkbox 'onclick' method getting resource undefined error.

i've added jsfiddle

function setcss() { if (this.checked)     $(this).closest('td').classname = "selected"; else     $(this).closest('td').classname = "deselected"; } 

you can quite using knockout css binding:

 <td data-bind="css: {'selected': selected,'deselected': !selected() }">       <!-- existing content -->  </td> 

i've updated your fiddle work in way.

this binding means "set 'selected' class if selected() evaluates truthy value, , set 'deselected' class if evaluates falsey".

you neaten css using :not(selected) instead of explicit deselected class


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -