I have a link that has a method attached to the onclick event. I am unable to edit the existing html or javascript method but I am able to add additional javascript.
I need to fire some jquery after the fixedMethod()
method completes.
So for example in the sample below I need to make the output 1, 2
instead of 2, 1
without changing the HTML of the link or fixedMethod()
but the rest of the javascript I can change.
This is a contrived example, in my actual use case I don't know how long the method will take to complete.
function fixedMethod(){
setTimeout(function(){console.log(1)}, 2000);
}
$("#someLink").click(function(){
console.log(2);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<a id="someLink" href="#" onclick="fixedMethod()">click here</a>
Is this possible?