This is a very simple, probably too simple question but I'm afraid my limited skills in jQuery require someone's help! Behold the shameful line of code:
onclick="javascript: $j('#'+openc).fadeOut('normal', function({
$j('#'+openc).fadeIn('slow')});
openc=+1;
alert('The city of ' + openc + ' is located in ' + openc + '.');"
By default, openc is set to 0.
Onclick, the div with the id 0 is faded out, and I wish to have div id 1 open, then openc to b updated to 1. I added the alert for my own sake. When I press once, it seems to work. When I press it again, it still alerts 1, thus my div id 1 fades out and right back in. I think I just need to add +1 to the fadeIn function with the onclick, so that it will always open openc+1 but..can't seem to get the syntax right.
Thanks!
EDIT: Perhaps my question was not clear enough, I figured I would add some info. I beg you to not suggest things such as adding event-handlers, I have no clue what that even means, I am a total noob at javascript/jQuery. All I need to do is this:
onclick, fadeout the div openc (which yes, is a number) ,fadein openc +1, and update openc to its own value +1.
This is for a pagination of sorts between divs. So say you land on div id=0, openc=0. You click on next, it should fadeout div0, fadein div1, and openc should now equal1. That way, the next time you click next, div1 fades out, and div2 appears, etc.
Hope that clarifies, thanks again!
onclickattribute of an element to assign a click event handler? Also, the W3C standards state that IDs must begin with a letter ([a-zA-Z]).+=rather than=+to perform addition and assignment using the single operator. The code is very difficult to read in its current state, but I did spot that.