blenderNetworkpatreonblender-logosdheartuserthtimesbookphotopencilmap-markerchevron-rightbancommentcommentstwitterfacebookrsschainnavicongoogle-plusenvelopelinkedinmail-replycalendar-otumblrredditstumbleuponshare-altbloggerflattrflag

using jquery to check if a <a href> was clicked

using jquery to check if a <a href> was clicked

Postby themitchel0 » February 24th, 2011, 1:43 pm

hello, again, im making some improvements to a script, and i was wondering if anyone knew how to check with jquery if an html link was clicked, any help would be nice!
themitchel0
Pro
Pro
 
Posts: 365
Joined: June 15th, 2010, 8:31 am

Re: using jquery to check if a <a href> was clicked

Postby IrascibleOne » February 24th, 2011, 8:48 pm

Off the top of my head, one way is that you could run a very short function that turns a variable to true when the link is clicked. Then when you need to check if it has been clicked, you just run a if statement on the variable. For instance:

Code: Select all
var clicked = false;
$('.linkclass').click(function(){
     clicked = true;
});

//Then, whereever you need it:
if(clicked == true){
    //Do stuff
}
Not sure if the syntax is all correct, I don't use jquery/javascript enough to know it off the top of my head right now and I've been doing a lot of php lately.
Image
User avatar
IrascibleOne
Site Admin
Site Admin
 
Posts: 1539
Joined: July 31st, 2008, 7:14 pm

Re: using jquery to check if a <a href> was clicked

Postby themitchel0 » February 26th, 2011, 10:52 pm

thanks!
themitchel0
Pro
Pro
 
Posts: 365
Joined: June 15th, 2010, 8:31 am
Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron