使用javascript在span标记中追加文本
试图在一个范围内从javascript编写测试使用javascript在span标记中追加文本,javascript,Javascript,试图在一个范围内从javascript编写测试 <span> <script type="text/javascript">document.write("thisStringIsGood".replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase(); }));</script> </span> 在Firefox和Chrome中进行测试
<span>
<script type="text/javascript">document.write("thisStringIsGood".replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase(); }));</script>
</span>
在Firefox和Chrome中进行测试时,对我来说效果非常好,但这是一个可怕的代码。除了使用document.write的普遍不可取性之外,您所拥有的一切都很好——还有更多的代码吗?调试器是否突出显示了该行?工作正常,@adeneo是的,这是一个可怕的代码是的,工作正常。。。。实际上,我正在XSLT for xml中使用这段代码。。。。让我更新我的问题
<xsl:for-each select="ColumnName">
<script type="text/javascript">document.write("thisStringIsGood".replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase(); }));</script>
<xsl:apply-templates />
</xsl:for-each>