|
|
Writing / Inserting html tags
|
Tutorials

Javascript

|
Topic |
Writing/Inserting a html code using javascript?
How to break the sequence of write method?
|
|
Explanation |
HTML Code:
HTML tags or code can also be added using document.write method.
i.e. Just use the html code as the argument for document.write or document.writeln functions
document.write("-- bold red --");
Example Code:
<script language=javascript>
document.write("-- <b>bold</b> <font color=red> red </font>--");
</script>
Result:
Break line for .write method :
document.write will append the string to the previous string.
i.e. if you call
document.write(" -- first line ---");
document.write(" -- second line ---");
the result will be as " -- first line --- -- second line ---";
So in order to break the lines in the browser you have to use an additional code "<br>" at the end.
e.g: document.write(" -- first line --- <br>");
Example Code:
<script language=javascript>
document.write(" -- first line --- <br>");
document.write(" -- second line --- <br>");
</script>
Result:
Test It:
Copy the code or type the code in to the text box shown below and click show.
|
| A Note |
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script.
Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.
|
|
|
|