Javascript jquery变量替换
这很有效Javascript jquery变量替换,javascript,jquery,string-concatenation,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='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();
你想要这个:
$("select[title='First Choice'] option[text=" + what + "]").remove();
你想要这个:
$("select[title='First Choice'] option[text=" + what + "]").remove();
这是javascript,不是php。。。这些类型的文本替换甚至不适用。您需要手动插入字符串。这是javascript,不是php。。。这些类型的文本替换甚至不适用。您需要手动插入字符串。这很好。。但为什么不这样做:$($(“”)后面的($(“”)attr(“value”,“5”).text(“+what+”))@cyberpine:在该代码片段中,字符串中有
what
。只需做:.text(what)
,效果很好。。但为什么不这样做:$($(“”)后面的($(“”)attr(“value”,“5”).text(“+what+”))@cyberpine:在该代码片段中,字符串中有what
。只要做:.text(什么)