<a id="aHw" href="#" callbackName="helloworld">test</a>
...
<script>
function helloworld() { alert('hello world'); }
</script>
...
question ; how can i produce callBack to pass another function
<script>
...
var cbName = $('#aHw').attr('callbackName');
foo( passfunction ); //How???
...
</script>
<script>
function foo(callBack)
{
callBack(); // call hello world.
}
</script>
thanks in advance.
Ok. So to have an anchor do something on MouseOver, you’d use this code:
You can pass a function to another function this way:
Or you can pass an anonymous function to the above:
If you’re trying to pass the name of a function as a string (which is a fundamentally bad idea and a terrible risk and hard to debug and DON’T DO IT), then you can use eval:
Or you might be able to get away with: