【发布时间】:2017-10-30 10:23:15
【问题描述】:
我正在尝试在 js 的方法中传递一个变量,以便我可以获得一些值作为返回,例如
getId: function (pos) {
var myVar = $('.myDiv li:nth-child(pos) .myInnerDiv .myInnerMostDiv').attr('id');
return myVar;
}
然后将其称为
this.getId(6); //where 6 is the pos
但这似乎不起作用。
我在这里做错了什么?
【问题讨论】:
-
$('.myDiv li:nth-child(' + pos +') .myInnerDiv .myInnerMostDiv').attr('id')
标签: javascript