【发布时间】:2011-07-08 06:05:54
【问题描述】:
我有以下 HTML:
<tr>
<td>
<img id='1' class='promote' src='/images/plus.png' />
<span>0</span>
<img id='1' class='demote' src='/images/minus.png' />
</td>
<td>
<img id='2' class='promote' src='/images/plus.png' />
<span>0</span>
<img id='2' class='demote' src='/images/minus.png' />
</td>
...
</tr>
接下来,我正在使用 jQuery ajax:
$('img.promote').click(function() {
$.ajax({
url: '/promote/' + this.id,
success: function(data) {
$(???).text(data.rating);
},
dataType: 'json'
});
});
$('img.demote').click(function() {
$.ajax({
url: '/demote/' + this.id,
success: function(data) {
$(???).text(data.rating);
},
dataType: 'json'
});
});
那么,我应该使用哪种 jQuery 选择器组合来代替“???”更改跨度标签之间的文本?还是我做错了?
【问题讨论】:
-
您是否尝试一次更改所有个跨度?还是只是一个特定的?
-
只有一个,它是评分系统的一部分。
标签: jquery ajax css-selectors