mercredi 24 janvier 2018

Toggle checkbox css styling using jQuery

I've created a filter controlled with checkboxes and modified the checkbox CSS to look like square buttons. Now I'd like to toggle the checkbox styling using jQuery to fill in the boxes (background-color: white). I've selected the :checked pseudo-class to attempt to toggle this styling, but obviously not correctly because the toggle doesn't change the background.

Thanks in advance for any guidance/assistance.

Here's the JS code ...

$('#onebdrm, #twobdrm').toggle(function() {
  $(this).toggleClass(':checked');
  return false;
});

Here's a fiddle.
https://jsfiddle.net/baskinco/e7utzowb/




Aucun commentaire:

Enregistrer un commentaire