M Akela
M Akela

Reputation: 249

Jquery error with value having space dynamically

Find selection with dynamic value having space

like 'ltrY2axisTopUp Acmount' I have

var val = 'ltrY2axisTopUp Acmount' now i want to find like this

$(':input[value=' + val + ']')

It says

Error: Syntax error, unrecognized expression: #lsltrY2axis option[value=ltrY2axisTopUp Acmount]

Upvotes: 0

Views: 37

Answers (2)

U.P
U.P

Reputation: 7442

Try

$(':input[value="' + val + '"]')

Notice " double quotes

Upvotes: 2

Arun P Johny
Arun P Johny

Reputation: 388316

Enclose the value in ""

$(':input[value="' + val + '"]')

Upvotes: 1

Related Questions