Creating valid XHTML when using jQuery .append()

≯℡__Kan透↙ 提交于 2019-12-11 11:17:35

问题


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:


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



来源:https://stackoverflow.com/questions/7166628/creating-valid-xhtml-when-using-jquery-append

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!