Example of using JavaScript code in HTML code, code javascript
<Script> </script> label
To use JavaScript in HTML, you need to use the <script> </script> label and define the type attribute value as text/javascript, as shown in the preceding alert pop-up prompt box:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Alert ("I Am a text prompt! ");
</Script>
Generally, JavaScript code alone is meaningless. JavaScript code is generally used together with HTML code, because JavaScript was originally generated to make up for HTML defects. The following is an example of using JavaScript code and HTML code:
Copy codeThe Code is as follows:
<Html>
<Head>
<Script type = "text/javascript">
Alert ("I Am a text prompt! ");
</Script>
</Head>
<Body>
<Div> image and text content </div>
</Body>
</Html>
Generally, JavaScript code (<script> </script> tag) is placed in the
Code for HTML + JAVASCRIPT
Please make a slight modification according to the example below
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "">
<Meta name = "Keywords" CONTENT = "">
<Meta name = "Description" CONTENT = "">
<Style>
<! --
# Foldheader {cursor: hand; font-weight: bold ;}
// -->
</Style>
<Script language = "JavaScript1.2">
<! --
Var head = "display :''"
Function change (){
If (! Document. all)
Return
If (event. srcElement. id = "foldheader "){
Var srcIndex = event. srcElement. sourceIndex
Var nested = document. all [srcIndex + 1]
If (nested. style. display = "none "){
Nested. style. display =''
}
Else {
Nested. style. display = "none"
}
}
}
Document. onclick = change
// -->
</Script>
</HEAD>
<BODY>
<Ul>
<Li id = "foldheader"> help 1 </li>
<Ul id = "foldinglist" style = "display: none">
<Li> help 1-content 1 </li>
<Li> help 1-content 2 </li>
<Li> help 1-content 3 </li>
</Ul>
<Li id = "foldheader"> help 2 </li>
<Ul id = "foldinglist" styl ...... remaining full text>
How to Use html code in javascript?
Do not use quotation marks. Try this way
Var tab = new TabBoard (document. getElementById ("radio_show"), document. getElementById ("radio_page"), document. getElementById ("radio_prev"), document. getElementById ("radio_next"), 140 );
[Loop]
Tab. add ('<a href = "{url}" {target}> </a> <a href = "{url}" title = "{title}" {target }>{ title} </a>' );
[/Loop]