这是我的javascript代码,该事件是许多行表的onkeyup!
function product(id)
{
$('#customers2').find('tr').click( function(){
var clicked = this;
});
var row = $(clicked).find('#tempnow').val();
if (row == "noncheck"){
$(clicked).find('#ett').val("");
$(clicked).find('#ett').prop("disabled", true);
}
else{
$(clicked).find('#ett').prop("disabled", false);
$.ajax({
url:baseurl+"/getinform/",
type: "POST",
dataType: "json",
data: {masp : id},
success:function(data) {
var thue = data['pcs_cl_pd_thue'];
$(clicked).find('#tyu').css("color", "red");
$(clicked).find('#tyu').val(thue);
}
});
}
}
当我使用firebug时,没有定义变量click?
答案 0 :(得分:1)
var clicked; // Define it outside
$('#customers2').find('tr').click( function(){
clicked = this; // Give it a value on click, from inside a function
next() // Now it has a value, call another function that'll do something with it
});
function next(){
$(clicked).find('#ett') // It works!
}