Reputation: 1651
I have this click button code
\$("#extractmonkeys").click(function () {
\$("#grapharea").html(" ");
\$("#paramselection").html(" ");
How can I trigger this code from somewhere else?
\$("#extractmonkeys").trigger("click");
Am i missing something?
please note: \$ is because i'm coding jquery inside perl ...
Upvotes: 1
Views: 2756
Reputation: 81700
To find out what's wrong
Upvotes: 0
Reputation: 93714
You're missing });
from the end of:
\$("#extractmonkeys").click(function () {
\$("#grapharea").html(" ");
\$("#paramselection").html(" ");
Otherwise, your \$("#extractmonkeys").trigger("click");
will work.
It could also be possible that the above code is not inside a document.ready:
\$(document).ready(function () {
/* code here */
});
In which case "#extractmonkeys" cannot be found and thus nothing happens.
Upvotes: 1
Reputation: 3436
function myFunction(){
$("#grapharea").html(" ");
$("#paramselection").html(" ");
}
$("#extractmonkeys").click(function () {
myFunction();
}
this way you can call your function from everywere
Upvotes: 1