Single vs Double Quotes (Very Confusing!!)
Page 1 of 1
Single vs Double Quotes (Very Confusing!!)
The row in the table would highlight whenever I mouse over it.This works perfectly in HTML but I would like to convert from HTML code to Javascritp code to make it more dynamic.
- Code: Select all
<html>
<body>
<TABLE border=1>
<TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='gold';" onMouseOut="this.bgColor='#FFFFFF';">
<TD>Mauritania</td><TD>21N</TD><TD>24N</TD><TD> </TD><TD> </TD>
</TR>
<TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='gold';" onMouseOut="this.bgColor='#FFFFFF';">
<TD>Myanmar</td><TD> </TD><TD>M TBA</TD><TD>M TBA</TD><TD> </TD>
</TR>
<TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='gold';" onMouseOut="this.bgColor='#FFFFFF';">
<TD>Nepal</td><TD> </TD><TD> </TD><TD> </TD><TD>M TBA</TD>
</TR>
</TABLE>
</body>
</html>
I tried to convert it to Javascript but it only gives me a blank screen.
This is very frustrating because I don't know where I'm going wrong.
Any comments of suggestions would be greatly appreciated.
- Code: Select all
<html>
<head>
<script type="text/javascript">
function init(){
document.writeln('<TABLE border=1>');
document.writeln('<TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='gold';" onMouseOut="this.bgColor='#FFFFFF';">');
document.writeln('<TD>Mauritania</td><TD>21N</TD><TD>24N</TD><TD> </TD><TD> </TD> </TR>');
document.writeln('<TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='gold';" onMouseOut="this.bgColor='#FFFFFF';">');
document.writeln('<TD>Myanmar</td><TD> </TD><TD>M TBA</TD><TD>M TBA</TD><TD> </TD></TR>');
document.writeln('<TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='gold';" onMouseOut="this.bgColor='#FFFFFF';">');
document.writeln('<TD>Nepal</td><TD> </TD><TD> </TD><TD> </TD><TD>M TBA</TD></TR></TABLE>')';
}
</script>
</head>
<body onload="init()">
</body>
</html>
--
Hotdeals
Hotdeals
Re: Single vs Double Quotes (Very Confusing!!)
yah its confusing and it also give a syntax error you have to use escape characters with these characters- Code: Select all
Code Outputs
\' single quote
\" double quote
\\ backslash
\n new line
\r carriage return
\t tab
\b backspace
\f form feed
for further detail please see
http://www.w3schools.com/js/js_special_characters.asp
Page 1 of 1