Document. createElement (& quot; A & quot;) has A good attribute for one day. Finally, the attributes in A are obtained.
Code 1:
<Html> <BODY> <script language = "JavaScript"> <! -- Var A = document. createElement ("A");. setAttribute ("href", "#");. appendChild (document. createTextNode ("some text"); document. getElementsByTagName ("BODY") [0]. appendChild (A); // --> SCRIPT </BODY> </ptml>
[Ctrl + A Select All Note: If you need to introduce external Js, you need to refresh it to execute]
Code 2:
<HTML> <HEAD> <TITLE> New Document </TITLE> script function newelement () {var a = document. createElement ("a");. href = "javascript: alert ('a link. ') ";. innerHTML = "aaa"; var img = new Image (); img. src = "http://img.baidu.com/img/post-jg.gif"; img. style. border = "none";. appendChild (img) document. getElementById ("oData "). appendChild (a); img. onmouseover = function () {this. src = "http://www.baidu.com/img/sslm1_logo.gif";} img. onmouseout = function () {this. src = "http://img.baidu.com/img/post-jg.gif";} script </HEAD> <BODY onload = newelement ()> <span id = "oData"> </SPAN> </BODY>
[Ctrl + A Select All Note: If you need to introduce external Js, you need to refresh it to execute]