I have html div with one attribute.
JavaScript
x
2
1
div exp_attribute="{"prop_val_name":1}">mydiv</div>
2
I tried to trigger click on it via jQuery like
JavaScript
1
4
1
$('div[exp_attribute={"prop_val_name":1}]').click(); // not working
2
$('div[exp_attribute=\{"prop_val_name":1\}]').click(); // not working with escaping special chars
3
$('div[exp_attribute=\{\"prop_val_name\":1\}]').click(); // not working with escaping more special chars
4
but keep getting error
JavaScript
1
2
1
Error: Syntax error, unrecognized expression: div[exp_attribute={"prop_val_name":1}]
2
so any idea how to handle the issue?
Advertisement
Answer
Better to escape everything
JavaScript
1
2
1
$('div[exp_attribute=\{\"prop_val_name\"\:1\}]').click();
2