我点击一个按钮进行AJAX.返回的是一个数组.然后对这个按钮的相对位置进行变化.
用的是$(this)方法.这个是错误的.this在AJAX里面貌似不是对应这个按钮.请问在回调函数里应该怎么定位这个按钮?
function bsaveclick() {
$full= $(this).parent().parent().children().eq(0).html();
$.post("change2.php", $full, function(msg) {
obj = $.parseJSON(msg);
alert(obj[1]);
$(this).parent().parent().children().eq(1).html(obj[1]);});}
用的是$(this)方法.这个是错误的.this在AJAX里面貌似不是对应这个按钮.请问在回调函数里应该怎么定位这个按钮?
function bsaveclick() {
$full= $(this).parent().parent().children().eq(0).html();
$.post("change2.php", $full, function(msg) {
obj = $.parseJSON(msg);
alert(obj[1]);
$(this).parent().parent().children().eq(1).html(obj[1]);});}
把$(this)换为$("#_TEST")
class也不行,设成class就变成全部变动了
或是用排除法$("img").not(".imgClass")
或是把这些img集中起来加个标签卡住<div id="imgWrapper"><img ....
$("#imgWrapper img")自由发挥啦~