JQuery:传递 $(this).parent();方法?
我有一个简单的脚本:
$('.expand').each(function(i){
var _Expand = $(this).parent();
ExpGroupBy(_Expand);
});
尝试通过类“expand”传递所有 的
但是 firebug 不断弹出错误:
'类型错误: formObj.getElementsByTagName 不是 函数'
有什么想法吗?
谢谢^^
I have a simple script:
$('.expand').each(function(i){
var _Expand = $(this).parent();
ExpGroupBy(_Expand);
});
Trying to pass the <tr>
of all <td>
with the class 'expand'
However firebug keeps popping up the Error:
'TypeError:
formObj.getElementsByTagName is not a
function'
Any ideas?
Thanks ^^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
只要函数知道参数是 jQuery 对象而不是 DOM 元素本身。如果函数需要 DOM 元素引用,您可以轻松地这样做......
As long as the function understands that the parameter is the jQuery object and not the DOM element itself. If the function expects a DOM element reference, you can easily do that like this...
parent()
返回一个 jQuery 对象。试试这个:parent()
returns a jQuery object. Try this instead:如果 ExpGroupBy 需要 DOM 元素,请将其调用为
ExpGroupBy(_Expand[0])
If ExpGroupBy expects DOM element call it as
ExpGroupBy(_Expand[0])
get(0) 返回封装在 jquery 对象中的元素。您也可以使用 _Expand.get(0)
get(0) returns the element encapsulated in jquery object. You can use _Expand.get(0) as well