admin管理员组文章数量:1297011
Can anybody help me out writing this on onClick event on href tag?
string x= "<a href=\"JavaScript:callfunction(event,'"+ y.id.tostring() + "');\">click</a>";
Can anybody help me out writing this on onClick event on href tag?
string x= "<a href=\"JavaScript:callfunction(event,'"+ y.id.tostring() + "');\">click</a>";
Share
Improve this question
edited May 31, 2012 at 15:41
Michael Berry
72.4k23 gold badges163 silver badges224 bronze badges
asked May 31, 2012 at 15:27
user957178user957178
6314 gold badges16 silver badges27 bronze badges
1
- 6 What are you trying to do? What is it doing? What is your question? – gcochard Commented May 31, 2012 at 15:29
3 Answers
Reset to default 6string x = string.Format(
"<a href=\"#\" onclick=\"callfunction(event, '{0}')\">click</a>",
y.id
);
why not something like :
string x= "<a href=\"#\" onclick=\"callfunction(event,'"+ y.id.tostring() + "');\">click</a>";
Just an alternative way using DOM responsible methods for this kind of task
var x = document.createElement('a');
x.href = "#";
x.onclick = function(evt) {
callfunction(evt, y.id.tostring())
}
<destination-node>.appendChild(x);
本文标签: javascripthow to write onclick event for href tagStack Overflow
版权声明:本文标题:javascript - how to write onclick event for href tag - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741649213a2390370.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论