Richard Young Richard Young - 4 months ago 13
jQuery Question

Add pre-written function to onclick of division

I have a division and I want a JavaScript function to fire when I click on the division. I've found ways of doing it, but they all involve writing the function and I just want to just fire to function and can't seem to get it to work. Can anyone help me?

<script type="text/javascript">
$('#item').click(view_summary(););
</script>

Answer

Try with

$('#item').click(view_summary);

you need to pass a function in argument (not to call the function directly unless view_summary return a function itself)