2011-08-26 27 views
0

如果一个jQuery对象传递给函数,我可以得到“正规军” JS出来的,所以我可以运行的东西,如:如果这是相当jQuery对象转换为常规的JS函数内

foo($(this)) 

function foo(node){ 
    var jsnode = regular js object 
    var num = (jsnode.id).substr((jsnode.id).length-1, 1); 
} 

复杂的我可以只使用jQuery ...只是好奇!

回答

5

您可以使用get方法:

var jsnode = node.get(0); //Returns the node at index 0 

或者你也可以使用数组符号:

var jsnode = node[0]; //Also returns the node at index 0 
0

是的,只是访问常规的JavaScript在node[0]