Creating valid XHTML when using jQuery .append()

2019-08-14 08:05发布

In the examples here: http://api.jquery.com/append/ they show straight HTML being used as an argument:

$('.inner').append('<p>Test</p>');

But the validator at W3 will object to this like so

Line 96, column 76: document type does not allow element "p" here
…ata).append("<p class='pag

How should I do this to get valid XHTML?

EDIT - Here is an example of what is written by PHP:

$('#citations_18401-01').html(data).append("<p class='paginated_link'><b>Result Pages:</b>&nbsp;<b class='paginated_link'>1</b>&nbsp;<a class='paginated_link' href='property_info.php?lot=18401-01&quote_set=1&limit=30&tab=3'>2</a>&nbsp;</p><p>&nbsp;</p>"); 

1条回答
放荡不羁爱自由
2楼-- · 2019-08-14 08:59

You have to wrap your inline jQuery with special tags for XHTML. See this article.

查看更多
登录 后发表回答