我想在给onchange文本框的onchange中调用一个函数。每当我将文本框放大时,都应该调用该函数。但我越来越myFunction(函数名称)是未定义的。这就是我所做的:功能未定义错误
var c = 0;
jQuery(document).ready(function() {
jQuery("#table_projection_value").dataTable({
"sAjaxSource": "includes/inc-projection-db.php?mode=projection_dataTable",
"bDestroy": true,
"bPaginate": false,
"bInfo": false,
"bFilter": false,
"bSort": false,
"aoColumnDefs": [
{
"aTargets": [0],
"mRender": function(data, type, row) {
return data + '<input type="hidden" class="user_id" name="user_id[]" id="user_id" value="' + row[4] + '">';
}
},
{
"aTargets": [1],
"mRender": function(data, type, row) {
return '<input type="text" onchange="myFunction();" class="form-control text-right projected_value" name="projected_value[]" id="projected_value_' + c + '_' + data + '" >';
}
}
],
"fnCreatedRow": function(nRow, aData, iDisplayIndex, iDisplayIndexFull){
c = c + 1;
}
});
function myFunction(){
$(":text").blur(function() {
alert("**");
var element=$(this); // you can get the element here
});
$(":text").focusout(function() {
alert(this.id + " focus out");
});
}
});
我该怎么办?
感谢花花公子,对你有所帮助。我知道了。但是现在,我面临另一个问题。我试图获取该文本框的值,我得到“TypeError:this.id.val不是函数”错误。如何解决这个问题并获得价值。这是我所做的: –
function myFunction(){ \t \t \t alert(“Coming!”); \t \t \t $( “:文本”)。模糊(函数(){ \t \t \t \t \t \t VAR元= $(本); //你可以得到元素在这里 \t \t \t}); \t \t \t $( “:文本”)。事件的内容(函数(){ \t \t \t警报(this.id + “集中了”); \t \t \t警报(( “#this.id”) .val()); \t \t \t // alert((this).val()); \t \t \t}); \t \t} –