How to manipulate with UL with jQuery in XML+XSL generated HTML?

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

This is the XML:

<?xml version="1.0"?> <?xml-stylesheet href="a.xsl" type="text/xsl"?> <root/> 

This is the a.xsl stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   xmlns:xs="http://www.w3.org/2001/XMLSchema"   xmlns="http://www.w3.org/1999/xhtml"   version="2.0" exclude-result-prefixes="xs"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template match="/">   <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;</xsl:text>   <html>     <head>       <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"/>       <script>         $(document).ready(           function() {             $('#list').append('<li>foo</li>');           }         );       </script>     </head>     <body>       <ul id='list'>         <li><a href="http://www.example.com">hi!</a></li>       </ul>     </body>   </html> </xsl:template> </xsl:stylesheet> 

The page is not updated by this jQuery manipulation. What is wrong? How to fix it?

回答1:

This is how it works instead:

$('#list').html('<li>foo</li>'); 


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