這個工程裏面......變量jQuery選擇
var start = $('.nodes:first>span>div');
var foo1 = $(".nodes:first>span>div>div>div>div>span>div");
var foo2 = $(".nodes:first>span>div>div>div>div>span>div>div>div>div>span>div");
var foo3 = $(".nodes:first>span>div>div>div>div>span>div>div>div>div>span>div>div>div>div>span>div");
var foo4 = etc,etc...
試圖鞏固這樣的事情...
var start = $('.nodes:first>span>div');
var separator = ">div>div>div>span>div";
var foo1 = $("start + 1*separator");
var foo2 = $("start + 2*separator");
var foo3 = $("start + 3*separator");
var foo4 = etc,etc...
一直得過且過了幾個小時,但對於這個語法脫離了我!任何指針?謝謝!
可能重複的[如何在jQuery選擇器中使用JavaScript變量](http://stackoverflow.com/questions/5891840/how-to-use-javascript-variables-in-jquery-selectors) – Phil
我寧願詢問是否有辦法*簡化*這些選擇器/你的HTML結構... – deceze