djbuddhi Posted February 23, 2008 Share Posted February 23, 2008 document.getElementById("div_id_naMr").innerHTML="hello"; will display the hello text in the web browser . i just want to diplay the hello in the web browser in the red color . How to color up the text with ajax i want to keep the color in the javascript file Quote Link to comment Share on other sites More sharing options...
mainewoods Posted February 24, 2008 Share Posted February 24, 2008 just innerHTML some html tags like the span with an inline style: document.getElementById("div_id_naMr").innerHTML='<span style="color:red;">hello in red!</span>'; always make sure you innerHTML complete and properly nested html with all closing tags or you'll have problems with some browsers. You can innerHTML any html including image tags, links, divs, and even whole html tables. You cannot innerHTML whole web pages with the HTML and BODY tags and you cannot innerHTML javascript, it will not execute. But other than that you can innerHTML any HTML: document.getElementById("div_id_naMr").innerHTML='<a href="?"><img src="myimage.jpg"></a><br><span style="color:red;">hello in red!</span>'; Quote Link to comment Share on other sites More sharing options...
djbuddhi Posted February 25, 2008 Author Share Posted February 25, 2008 thanks a lot ;D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.