2016-08-03 1 views
-3

startPanel変数の値が5の場合は、"$('.sp .tabs span:nth-child(5)').trigger('click');""$('.sp .tabs span:nth-child('+ startPanel + ')').trigger('click');"に相当します。

答えて

6

結果の文字列は同じです:

var startPanel = 5; 
 
var str1 = '.sp .tabs span:nth-child(5)', 
 
    str2 = '.sp .tabs span:nth-child('+ startPanel + ')'; 
 
console.log(str1 === str2); // true

だから、$を呼び出すときに使用しているかは重要ではありません。

関連する問題