javascript - How to store HTML id as a js variable? -



javascript - How to store HTML id as a js variable? -

i writing webpage have 200+ links per page. each link has unique id matches id in frame. want run onmouseover function alter text color of both links across frames. here's i've got far.

<html><head><title>test</title> <script> function hey() {var id=//help please; document.getelementbyid(id).style.color = "red";} function bye() {var id=//help please; document.getelementbyid(id).style.color = "black";} </script> </head> <body> <a id="1" class="word" onmouseover="hey()" onmouseout="bye()">hello</a> <a id="2" class="word" onmouseover="hey()" onmouseout="bye()">world</a>.... </body></html>

any thoughts?

pass id function:

<html><head><title>test</title> <script> function hey(id) {document.getelementbyid(id).style.color = "red";} function bye(id) {document.getelementbyid(id).style.color = "black";} </script> </head> <body> <a id="1" class="word" onmouseover="hey(this.id)" onmouseout="bye(this.id)">hello</a> <a id="2" class="word" onmouseover="hey(this.id)" onmouseout="bye(this.id)">world</a>.... </body></html>

javascript html variables getelementbyid onmouseover

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -