I can't get a javascript to call a function on one click. I would have to click the button several times in order for it to execute. here is what I have tried so far:
<a href="javascript:delete_todo(4);void(0)"><img border="0" align="absmiddle" src="b_x.gif"></a>
<a href="javascript:delete_todo(4)"><img border="0" align="absmiddle" src="b_x.gif"></a>
<a href="javascript:void(0);" onclick="javascript:delete_todo(4)"><img border="0" align="absmiddle" src="b_x.gif"></a>
<a onclick="javascript:delete_todo(4)"><img border="0" align="absmiddle" src="b_x.gif"></a>
The code is added by another javascript function that adds the line of code to a table td using .innerHTML
Has anyone had this problem and found a solution?
Event handlers should always be in the onclick. Using javascript:
is bad form.
<a href="#" onclick="delete_todo(4);return false;">...</a>
Hmm... Try to remove javascript:
in onClick
atribute. Here is working example in jsFiddle: http://jsfiddle.net/ep7R9/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.