mardi 17 octobre 2017

Minification of jquery / javascript for checkbox links

I have written a couple simple lines of code that allows checkboxes in a sidebar navigation when clicked to send the user to a specified link. The checkboxes work as filters.
here is the HTML for the checkbox:

<li class="inactive" aria-selected="false">
<input id="path1" type="checkbox" value="Accessories">
<a href="href">Accessories</a>
</li>

And the jquery / javascript that creates the interaction:

    $('#path1').click(function(){ 
                 window.location='href'; //href would be a unique link
   });

The issue isn't getting this interaction to work, I'm having a logic problem. The way it's written is it's targeting the id of the checkbox. It isn't scalable. 8 links aren't so bad, but 500 links, and so on, you get the idea.

Is there a way to make this




Aucun commentaire:

Enregistrer un commentaire