宝哥软件园

$ 基于jQuery的getScript方法加载javaScript文档解析

编辑:宝哥软件园 来源:互联网 时间:2021-09-03

1.这两个文件的代码如下:

Scriptfunction Ajax(){ //在9-4.html修改Ajax()函数$。getscript ('9-8.js ',函数(数据){var html=' table border=' 1 '单元格填充=' 2 ';$.每个(注释,函数(Index,comment){ html=' trtd ' comment . username ' :/tdtd ' comment[' content ']'/TD/tr ';}) //comment['username']也可以写成comment . username html='/table '/alert(' hello ');$('#target ')。html(html);} );}/script input type=' button ' value=' Ajax submit ' onclick=' Ajax();'/div id='target'/div2。

3.分析:

注释是一个数组。注释是一个对象。

注释是一个数组,特别是json数组,注释的每个元素都是json对象,而不是数组。因为它是一个json对象,所以有两种方法可以获取值:comment.attribute或comment['attribute']

注释是一个数组。注释是一个对象。我也这么认为。有两种方法可以引用json对象的属性,即comment.attribute或comment['attribute']。然而,对于一般的对象,似乎只能用comment.attribute的形式来引用它们的属性。我不知道您还可以像这样引用json对象的注释['attribute']。我以为这是一个数组。这就是json和数组的区别,它有自己的特殊性。以上美元。基于jQuery的getScript方法加载javaScript文档分析是边肖与大家分享的全部内容。希望能给大家一个参考,支持我们。

更多资讯
游戏推荐
更多+