开发者

XHTML valid way to replace text with jquery

I have the following code

$("#FOO").hover(function() {
    $(this).html('<p><a href="somepage.php" target="_self">first text</a></p>');
    }, function() {
    $(this).html('<p><a href="somepage.php" target="_self">hovered text</a><开发者_StackOverflow;/p>');
});

Is it improper to put <p> & <a> tags in the .html function? It is invalid XHTML and I'd like to make it cleaner. thanks!

from w3c validator: Error Line 134, Column 83: end tag for element "A" which is not open

the next error is "end tag for element "p" wich is not open. its just reading those tags weird.

….html('<p><a href="somepage.php" target="_self">first text</a></p>');


It's fine. You could use a $("#FOO p") selector if its really bothering you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜