Sharing and innerHTML onMouseOver
<Html> <Script type = "text / javascript"> <! - function change_desc () { //desc.innerHTML="Pomenyali contents of the paragraph with id = 'desc' "; not universal version . Document.getElementById ( "desc") innerHTML = "Changed the content of the paragraph with id = 'desc'"; } -> </ Script> <P id = "desc"> Passage to change the text </ p> <a href="#" onMouseOver="change_desc()"> Change text </a> </ Html>
This example may be a little easier, for example, change the text in the paragraph on the different options and to return it to its original state after the retraction of a mouse pointer using predefined string constants:
<Html> <Script type = "text / javascript"> <! - default_text = "Standard text"; text1 = "Accordingly text1"; text2 = "Accordingly text2"; function change_desc (v) { //desc.innerHTML="Pomenyali contents of the paragraph with id = 'desc' "; not universal version . Document.getElementById ( "desc") innerHTML = v; } -> </ Script> <P id = "desc"> Passage to change the text </ p> <! - Launching our microfunction with parameters in the form of name of the constant with the text -> <a href="#" onMouseOver="change_desc(text1)" onMouseOut="change_desc(default_text)"> Change the text on the first </a> <a href="#" onMouseOver="change_desc(text2)" onMouseOut="change_desc(default_text)"> Change the text on the second </a> </ Html>
Note:
If the test works JavaScript FireBug displays "" the name of a variable, constant or function 'is not defined "is necessary to check the correctness of your code. For example, if the contents of the unscreened constant present quotation marks ( "), and before the announcement function may be missing a semicolon (;).
Comments
Commenting, keep in mind that the content and the tone of your messages can hurt the feelings of real people, show respect and tolerance to his interlocutors, even if you do not share their opinion, your behavior in terms of freedom of speech and anonymity offered by the Internet, is changing not only virtual, but real world. All comments are hidden from the index, spam control.