It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

CSS with Javascript??

CSS with Javascript??

Postby hiyatran on Fri Mar 04, 2011 1:59 am

I am able to incorporate CSS into the HTML, like this:
Code: Select all
<tr><td style="background-color:#FFFF00;">test</td></tr>


How can I incorporate CSS into javascript?
Code: Select all
document.writeln("<tr><td style="background-color:#FFFF00;">"+ "test" + "</td></tr>");


The javascript code doesn't work or this is it even possible?

Thanks
hiyatran
 
Posts: 18
Joined: Mon Jun 21, 2010 1:53 am

Re: CSS with Javascript??

Postby bardonw on Mon Apr 11, 2011 6:46 pm

Perhaps this is sort of what you are asking for:
Code: Select all
<table>
<script type="text/JavaScript">
document.write("<tr><td style=\"background-color:#FFFF00;\">" + "test" + "</td></tr>");
</script>
</table>


You will notice that I escaped the double quotes with backslashes. Another thing to notice is that you only want to run that code if it is being run between the starting and ending table tag. Otherwise, you may want to reference the table with JavaScript and than use the insertRow and insertCell functions.
bardonw
 
Posts: 7
Joined: Tue Feb 15, 2011 4:16 pm


Who is online

Users browsing this forum: No registered users and 8 guests