How can one call two separate action with the same event in

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
drayarms
Forum Contributor
Posts: 134
Joined: Fri Dec 31, 2010 5:11 pm

How can one call two separate action with the same event in

Post by drayarms »

Hello all, I recently made the switch from JS to JQ. In JS, it was possible to use a single inline event to call several actions, by merely separating the actions with a semi colon. In JQ, this technique does not work. Here's an example of what I'm talking about.

Code: Select all


 onclick = '$(this).parent().next().next().children().eq(0).show(); (this).next().hide();'> 	 

I tried using two onclicks like this:

Code: Select all


 onclick = '$(this).parent().next().next().children().eq(0).show();' onclick='$(this).next().hide();'> 	 
but in this case, only the first onclick call works. The second doesn't. So my question is, how can one achieve this if at all possible? I don't want to use functions in the head section because this particular problem requires me to use inline event calls. Thanks.
KCAstroTech
Forum Commoner
Posts: 33
Joined: Sat Aug 27, 2011 11:16 pm

Re: How can one call two separate action with the same event

Post by KCAstroTech »

In your first code example you forgot the $ in $(this).next().hide(); Otherwise there should be nothing wrong with that solution. The second solution won't work as you are essentially overwriting the first click function with the second.
Post Reply