<Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> <Title> test (innerText and innerHTML) </title> <Script type = "text/javascript"> Function TestOutput (){ Var myLink = document. getElementById ("lnk "); Alert ('nertext --> '+ myLink. innerText ); // Obtain the Baidu website Alert ('nerhtml --> '+ myLink. innerHTML ); // Get a hundred <font color = "red"> website </font> } Function EditInnerText (){ Var myLink = document. getElementById ("lnk "); MyLink. innerText = "phoenixnet "; } Function EditInnerHTML (){ Var myLink = document. getElementById ("lnk "); MyLink. innerHTML = "<font color = 'blue'> Phoenix </font> "; } Function dynamicButtonClick (){ Alert ('I am a dynamic create '); } Function CreateButton (){ Var div = document. getElementById ("divMain "); Div. innerHTML = "<input type = 'button 'value = 'click me' Onclick = 'dynamicbuttonclick () '/> "; } </Script> </Head> <Body> <A href = "http://www.baidu.com" id = "lnk"> Hundreds of <font color = "red"> websites </font> </a> <Input type = "button" value = "test" onclick = "TestOutput ()"/> <Input type = "button" "value =" Modify InnerText "onclick =" EditInnerText () "/> <Input type = "button" "value =" Modify InnerHTML "onclick =" EditInnerHTML () "/> <Div id = "divMain"> </div> <Input type = "button" value = "dynamic Add button" onclick = "CreateButton ()"/> </Body> </Html> |