0

I am working on this Wordpress website and i am a using a bit of JS to animate the table.

What i need is to "filter" the Table rows when a checkbox on top is selected. For example when Zimmer -> 4.5 is selected, only the rows with class .zimmer4 are displayed. I am using now this script but does not works:

JS:

$(document.body).on('change', "#zimmer5", function() { 
    $("#tableID tr.zimmer5").toggle(!this.checked); 
});    

$(document.body).on('change', "#zimmer4", function() { 
    $("#tableID tr.zimmer4").toggle(!this.checked); 
});

$(document.body).on('change', "#zimmer3", function() { 
    $("#tableID tr.zimmer3").toggle(!this.checked); 
});

$(document.body).on('change', "#zimmer2", function() { 
    $("#tableID tr.zimmer2").toggle(!this.checked); 
});

This is the HTML code i am using for the buttons

HTML

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<span class="dropdown">
        <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Zimmer
        <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<form class="filter">
<input id="zimmer4" class="unchecked" type="checkbox">4.5
<br>
<input id="zimmer3" class="unchecked" type="checkbox">3.5
<br>
<input id="zimmer2" class="unchecked" type="checkbox">2.5
<br>
</form>
</ul>
</span>
7
  • 1
    How did you integrate this script into your website? Are the functions already available? Do you get any errors? Is this inside an onready block? Commented May 30, 2016 at 13:39
  • thats jquery you are using, not vanilla javascript, have you loaded jquery? Commented May 30, 2016 at 13:39
  • I am using a plugin in. srd.wordpress.org/plugins/css-javascript-toolbox i used the exactly the same plugin in on another website and it works: birsmatt.ch/wohnungen Commented May 30, 2016 at 13:41
  • Fix what? You stated your objective but haven't explained what the problem is. "does not work" is not a proper problem statement. Please include relevant html in the question Commented May 30, 2016 at 13:41
  • I see the following JS error: "Error: TypeError: $ is not a function Source File: weierweg-liestal.ch/wohnen Line: 1640" That should put you down the right path. Commented May 30, 2016 at 13:48

1 Answer 1

1

replace your $ sign with jQuery

Sign up to request clarification or add additional context in comments.

1 Comment

So easy. THANK YOU!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.