jquery变量替换

时间:2012-03-29 16:33:44

标签: javascript jquery string-concatenation

这有效..

$("select[title='First Choice'] option[text='hello']").remove();

这种情况的许多变化都没有..我知道这是愚蠢的。

var what='hello';

    $("select[title='First Choice'] option[text=$what]").remove();

也尝试了这些。

$("select[title='First Choice'] option[text=$(what)]").remove();
$("select[title='First Choice'] option[text='$what']").remove();
$("select[title='First Choice'] option[text=$what.val()]").remove();

1 个答案:

答案 0 :(得分:6)

你想要这个:

$("select[title='First Choice'] option[text=" + what + "]").remove();