propb. very simple, but not for me.
Looking to pass a variable on a click function to show either div a or div b based on the a link clicked. My code is something like this
$('.view').click(function() {
var id = this.id.replace('view_', "");
if(id=1) { $('#show').show('slow'); }
if(id=2 ) { $('#show2').show('slow'); }
$('#categories').hide('slow');
return false;
});
});
But OBVIOUSLY the if statements are wrong – I know that I am just using them as an example. Any suggerstions?
Thanks in adavance
Best Answer
You are assigning the value of
1
toid
instead of testing for a match:Here is what it should look like:
If you find yourself making this mistake a lot, you should switch the test around: