Want value of $bhai in javascript

末鹿安然 提交于 2019-12-01 12:12:54
Jevgeni

The reason for that is because document.getElementById returns first element matching that id.

Try changing your code like 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);
}

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!