【发布时间】:2011-05-17 16:53:43
【问题描述】:
我有这个代码
var users = result.users; // array
$("#dialog:ui-dialog").dialog("destroy");
$("#dialog-confirm").dialog({
resizable: false,
height: 140,
modal: true,
open: function() {
$(this).children('div.dialog-text').replaceWith("<b>New text goes here</b>");
},
buttons: {
"Okay": function() {
$(this).dialog("close");
},
Cancel: function() {
is_okay = 0;
$(this).dialog("close");
}
}
});
其中数组包含的数据形式为
{"ss":"Sandra Schlichting","fn":"Full name"}
我想要完成的是以(为便于阅读而插入空格)的形式获取数组的内容
<table>
<tr> <td>Initials</td> <td>Full Name </td> </tr>
<tr> <td>ss </td> <td>Sandra Schlichting</td> </tr>
<tr> <td>fn </td> <td>Full name </td> </tr>
</table>
并将其替换为 <b>New text goes here</b> in
$(this).children('div.dialog-text').replaceWith("<b>New text goes here</b>");
据我所知,$.each() 应该用于此目的。
但我仍然不知道如何开始。
谁能帮帮我?
【问题讨论】:
标签: javascript jquery