Want value of $bhai in javascript

后端 未结 1 521
予麋鹿
予麋鹿 2021-01-15 20:11
#!/bin/sh

echo \"Content-type: text/html\"
echo \"\"
echo \'\'
echo \'\'
echo \'

        
相关标签:
1条回答
  • 2021-01-15 20:54

    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.

    0 讨论(0)
提交回复
热议问题