I’m trying to convert all my old javascripts to jquery but I’m a bit confused how can I convert my click event with attr. The old javascript looks something like:
function MyFunction(string1, string2){
doSomething(string1);
doSomethingElse(string2);
}
And then I call it with
<a href="javascript:MyFunction('string 1','string 2');">CLICK HERE</a>
Can I do this with the jquery click()? Or how can I send the two strings with an event in jquery?
I need to define the two strings in the link like I’m doing it now because the strings will vary.
Edit: I have removed my jquery-code-try as it only confused 🙂
Naeem’s solution is good, and it’s hard to tell the conditions of that link. Is it dynamically created? If so you can set attributes, like
<div id="myLink" a="string1" b="string2">CLICK HERE</div>and then