Hell.Bent
Hell.Bent

Reputation: 1677

jquery variable substitution

this works ..

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

A number of variations of this does not .. i know this is stupid.

var what='hello';

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

also tried these.

$("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();

Upvotes: 0

Views: 1331

Answers (1)

Colin Brock
Colin Brock

Reputation: 21565

You want this:

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

Upvotes: 6

Related Questions