:
するとあなたは二重引用符を使用している「HTMLでは、単一引用符'は、その属性でを使用しています。
この
<div id="rating_poll_front" onmouseover="this.css("background-color","red")" onmouseleave="this.css("background-color","yellow");" style="background-color:yellow;"></div>
は次のようになります。
<div id="rating_poll_front" onmouseover="this.css('background-color','red')" onmouseleave="this.css('background-color','yellow');" style="background-color:yellow;"></div>
第二:PHPコードとして
もそうPHP内部の単一引用符の前にバックスラッシュを使用する単一引用符を使用しています:
例:
echo '<div id="rating_poll_front" onmouseover="this.css(\'background-color\',\'red\')" onmouseleave="this.css(\'background-color\',\'yellow\');" style="background-color:yellow;"></div>';
3番目のJavaScriptのcss()などのプロパティはありません、this.styleを使用します。backgroundColorの:
だからあなたのコードでは、最終的には次のようになります。
echo '<div id="rating_poll_front" onmouseover="this.style.backgroundColor=\'red\';" onmouseleave="this.style.backgroundColor=\'yellow\';" style="background-color:yellow;">Hello</div>';
それがブラウザに来るとき、それはスニペットのように実行します:
<div id="rating_poll_front" onmouseover="this.style.backgroundColor='red';" onmouseleave="this.style.backgroundColor='yellow';" style="background-color:yellow;">Hello</div>
'this'ができます'.css()'を持たないHTMLElementオブジェクトです。代わりに '$(this)'を使用してください。 'this'はjQueryオブジェクトではないため –
です –