SV: [thelist] Basic JavaScript question

Marcus Andersson marcan at home.se
Sat Oct 18 11:11:47 CDT 2003


><td class="menuTable"><a href="news.jsp" class="menuText"
onmouseover="var m22 = getElementById('m22');
m22.firstChild.nodeValue='<div
class='menuText';>Hello</div>';">News</a></td>

>I'm a tad confused between languages, I thought of using \' but I think
that's Perl. I tried " because " and ' alternate I think in PHP. And I
tried &apos; but that's HTML. So how, in JavaScript, do I overcome the
"/' issue?

Try:
<td class="menuTable"><a href="news.jsp" class="menuText"
onmouseover="var m22 = getElementById('m22');
m22.firstChild.nodeValue='<div
class=\"menuText\";>Hello</div>';">News</a></td>

I simply replaced 'menuText' around \"menuText\". It should work.

Btw: Do you have to do it that way? Isn't it easier/cleaner to call an
event handling function instead? You might think "I don't want the extra
work to write a function and call it!". But if you had you wouldn't have
had this problem in the first place and saved more time than you
would've lost on writing the extra function.

/Marcus



More information about the thelist mailing list