www.webdeveloper.com
Results 1 to 3 of 3

Thread: innerText or textContent with Style

  1. #1
    Join Date
    Sep 2009
    Posts
    172

    innerText or textContent with Style

    All,
    I have the following code:
    Code:
    <div id="upload_done"></div>
    
    <script language="javascript">
    function uploaderStatusChanged( uploader ) {
    	upload_status = uploader.getStatus()
    	if(upload_status==1){
    	traceEvent( "The files are being uploaded!" );
    	}else{
    	traceEvent( "The files have successfully uploaded!" );
    	}
    }
    </script>
    <script language="javascript">
    function traceEvent( message ) {
    	document.getElementById("upload_done").innerText = message; // for IE
    	document.getElementById("upload_done").textContent = message;
    }
    </script>
    When I use the innerText and textContent I'd like the font color to be red. How can I go about doing this? Also I tried to add some line breaks after the message but wasn't able to do that either. I tried to do this:
    Code:
    <script language="javascript">
    function traceEvent( message ) {
    	document.getElementById("upload_done").innerText = message + "\n\n"; // for IE
    	document.getElementById("upload_done").textContent = message + "\n\n";
    }
    </script>
    but was unsuccessful in that. Any help is appreciated. Thanks in advance.
    Last edited by treeleaf20; 02-28-2011 at 09:43 PM.

  2. #2
    Join Date
    Feb 2011
    Posts
    231
    Hy
    Try use innerHTML
    document.getElementById("upload_done").innerHTML = '<font color="red">'+message+'</font><br />';

  3. #3
    Join Date
    Sep 2009
    Posts
    172
    That did the trick, just wanted to confirm that innerHTML is ok for use cross browsers? In the other example I needed two different ones so just want to make sure that is not the same thing here. Thanks for the help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles