JQuery函数返回一个对象,但它被集成为未定义对象
JQuery function returning an object but its being integrated as undefined
我正试图在单击按钮时从函数中获取一个对象。
该函数返回一个对象(使用Google工具检查),但返回值"tr"变为未定义。
按钮
$("#btnView").on("click", function () {
var tr = GetActiveRow(); <-- the tr value is coming as undefined
var itemNumber = tr.find("td").eq(0).html();
});
功能
function GetActiveRow() {
var rows = $(".datagrid tr:gt(0)");
rows.each(function (index) {
//If its currently active override it so we can mark new row
var rowdata = $(this).data;
if ($(this).data("isActive") == true) {
alert($(this));
return $(this).get(); <-----object is being turned because the alert message is displayed
}
});
}
i跳出循环,在底部添加了return语句,它成功了:D
function GetActiveInvoiceRow() {
var trRow = null;
var rows = $(".datagrid tr:gt(0)");
rows.each(function (index) {
//If its currently active override it so we can mark new row
var rowdata = $(this).data;
if ($(this).data("isActive") == true) {
trRow = $(this);
return;
}
});
return trRow;
}
相关文章:
- 为什么“;未定义的“;在JavaScript中结束循环
- 要求未定义JS回调参数
- 如何检查管道中未定义的项目
- TypeError:无法读取属性'推'未定义的JavaScript
- $window.ga在AngularJS事件中未定义
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 为什么grunt contrib connect的中间件选项的第三个参数是未定义的
- 无法获取属性'selectedIndex'的未定义引用或null引用
- 如何消除代码中的未定义和其他问题
- 未捕获的ReferenceError:$未定义
- this.router在AngularJS 2中未定义
- 未捕获的类型错误:无法读取属性'删除'的未定义
- 节点fs.stat名称未定义
- 尝试在PHP中回显输入文本时出现未定义的索引错误
- Jquery未定义函数正在停止其他操作
- AngularJS指令出错-无法读取属性'编译'的未定义
- 这.SOMETHING 总是返回未定义的 - extjs
- 无法获取属性'Id'使用Knockout.js的未定义或空引用API
- Wordpress中带有JQuery Accordion的未定义匿名函数
- JQuery函数返回一个对象,但它被集成为未定义对象