-1

我已经编写了一个通过 jQuery 动态加载 html 的代码

$("table").eq(5).html('<table><tr><td>some data</td></tr></table><script language="JavaScript">function TCN_reload(from){}</script><table><tr><td>some data</td></tr></table>'); 

如果我使用此代码,则遇到页面加载错误。但是如果我删除该脚本,则没有错误,但我也想要该脚本。

请帮帮我!

谢谢!

4

2 回答 2

1

没有理由在 dom 元素中动态插入 javascript。删除javascript。它会起作用

要添加 javascript,您可以按照此操作

将 javascript 放入 jquery .html 函数中

于 2012-05-28T10:01:13.637 回答
0

更改<script language="javascript"><script type="text/javascript">。查看下面的详细说明

type = content-type :

This attribute specifies the scripting language of the elements contents and overrides the default scripting language. The scripting language is specified as a content type (e.g., "text/javascript" ). We have to supply a value for this attribute. There is no default value for this attribute.

language ="JavaScript" :

This attribute specifies the scripting language of the contents of this element. Its value is an identifier for the language, but since these identifiers are not standard, this attribute has been deprecated(outdated by newer constructs) in favor of type.
于 2012-05-28T09:48:42.637 回答