0

I've got a label in view with the ID filterOff and this jquery:

$(document).ready(function () {
$('#filterOn').click(function () {
    $('#filters').hide();
    $(this).attr('id', 'filterOff');
});
});

$(document).ready(function () {
$('#filterOff').click(function () {
    $('#filters').show();
    $(this).attr('id', 'filterOn');
});
});

It works on the first instance either way around though doesn't work for the 2nd click. I can't work out what's wrong with it? The ID is changing i've checked select element in developer view, though it doesn't work.

Katie
  • 25
  • 6
  • 1
    At the time you do `$('#filterOff').click(function () { ...` there is not element with that id. You need to do `$(document).on('click', '#filterOff' , function() { ...` – connexo Mar 10 '18 at 20:42
  • @connexo works perfectly thank you, didn't know :) – Katie Mar 10 '18 at 21:06

0 Answers0