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.
精彩评论