本文介绍了想要javascript中$ bhai的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I am new in this, please help me in this.
Thanks in advance推荐答案
原因是因为 document.getElementById 元素匹配 id 。
尝试更改您的代码,如下所示:
Try changing your code like this:
onclick = myFunction(this) - 您可以在这里使用 this ,它会引用元素被点击
onclick=myFunction(this) - you can use this here, it will reference the <a/> element being clicked
function myFunction(movieElement) { var mtype = movieElement.text; alert(mtype); }请注意,这被认为是不好的做法,如果您使用非 id 属性的独特值。正如名称所示,它应该是识别属性,并且是整个文档的唯一属性。
Please also note, that it's considered to be bad practice, if you use non-unique values for id attribute. As the name indicates it should be the identifying attribute and unique for the whole document.
这篇关于想要javascript中$ bhai的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!