jquery变量替换

Hel*_*ent 0 javascript jquery string-concatenation

这工作..

$("select[title='First Choice'] option[text='hello']").remove();
Run Code Online (Sandbox Code Playgroud)

这种情况有很多变化......我知道这是愚蠢的.

var what='hello';

    $("select[title='First Choice'] option[text=$what]").remove();
Run Code Online (Sandbox Code Playgroud)

也试过这些.

$("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();
Run Code Online (Sandbox Code Playgroud)

Col*_*ock 6

你要这个:

$("select[title='First Choice'] option[text=" + what + "]").remove();
Run Code Online (Sandbox Code Playgroud)