Change html style : JavaScript DHTML examples (example source code) » HTML » HTML Style

JavaScript DHTML
C++
Java Products
Java Articles
JavaScript DHTML Home  »   HTML   » [  HTML Style  ]   
 



Change html style

Please note that some example is only working under IE or Firefox.


/*
JavaScript Bible, Fourth Edition
by Danny Goodman 

John Wiley & Sons CopyRight 2001
*/

<HTML>
<HEAD>
<TITLE>applyElement() Method</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function applyOutside() {
    var newItem = document.createElement("EM")
    newItem.id = newItem.uniqueID
    document.all.mySpan.applyElement(newItem)
}
function applyInside() {
    var newItem = document.createElement("EM")
    newItem.id = newItem.uniqueID
    document.all.mySpan.applyElement(newItem, "inside")
}
function showHTML() {
    alert(document.all.myP.outerHTML)
}
</SCRIPT>
</HEAD>
<BODY>
<H1>applyElement() Method</H1>
<HR>
<P ID="myP">A simple paragraph with a <SPAN ID="mySpan">
<FONT SIZE=+1>special</FONT></SPAN> word in it.</P>
<FORM>
<INPUT TYPE="button" VALUE="Apply <EM> Outside" onClick="applyOutside()">
<INPUT TYPE="button" VALUE="Apply <EM> Inside" onClick="applyInside()">
<INPUT TYPE="button" VALUE="Show <P> HTML..." onClick="showHTML()"><BR>
<INPUT TYPE="button" VALUE="Restore Paragraph" onClick="location.reload()">
</BODY>
</HTML>
Related examples in the same category
1.  Paragraph Style
2.  Make text bold by replaces it in the tree with an Element node
3.  Using document create Style Sheet
4.  Reading the canHaveChildren Property
5.  Change the Text style Properties
6.  Using getBoundingClientRect()
7.   Dynamically Updating Styles Using DHTML
8.  Get Element style
9.  'EM' and 'P' element








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.