理解 JavaScript 函数
我对Javascript一无所知,我试图理解这段代码:
<a href="javascript:void(0);" onClick='toggle_detail(this, "value-computations", "3")' ">
我不理解的部分与指示onClick='toggle_detail..
的部分有关,这是一个自定义的吗?函数还是原生 Javascript 函数?
最终,我希望重写此锚标记,以便单击时显示
,第二次单击时隐藏
。非常感谢所有帮助,因为我对 Javascript 一无所知。
I don't really know anything about Javascript and I am trying to understand this piece of code:
<a href="javascript:void(0);" onClick='toggle_detail(this, "value-computations", "3")' ">
The part I don't understand relates to the portion that indicates onClick='toggle_detail..
Is this a custom function or a native Javascript function?
Ultimately I am looking to re-write this anchor tag so that on click it displays <div class="details">
and on the second click it hides the content of <div class="details">
.
All help is greatly appreciated, as I know nothing about Javascript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
toggle_detail 是一个自定义函数。它应该在页面的其他位置定义,或者在页面链接到的脚本中定义。 这里是关于 javascript 的很好的参考/教程。
toggle_detail is a custom function. It should be defined somewhere else on the page, or in a script that the page links to. Here's a good reference/tutorial on javascript.
你是对的。这是一个自定义函数。它已在其他地方定义,或者在
<; 中。 script >
标签实际显示代码,或者它已在<; 中引用。 script >
标签具有src
属性。You're correct. It's a custom function. It has been defined elsewhere, either in a
< script >
tag that actually shows code, or it's been referenced in a< script >
tag that has asrc
attribute.切换详细信息是一个自定义功能。
编写良好的toggle_detail 函数根本不需要您更改锚标记。通常,调用切换的函数会来回翻转设置,例如另一个元素的可见性
Toggle detail is a custom function.
A well written toggle_detail function wouldn't require you to change the anchor tag at all. Usually, a function that called toggle would flip a setting back and forth, like visibility of another element