且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用jQuery .append当创建有效的XHTML()

更新时间:2023-11-27 23:04:46

您必须包装内联的jQuery与XHTML特殊标签。请参见这篇文章

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>"); 

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