Reputation: 9184
I have such code:
$("input[id="+id.slice(0,-1)+"-br-"+brand+"].qnt_to_cart").show();
which generate me:
input[id=02620-br-FEBI BILSTEIN].qnt_to_cart
But i need to see something like:
input[id="02620-br-FEBI BILSTEIN"].qnt_to_cart
So what i need to write? How to set quote in quote?
upd
why i still see:
Uncaught Error: Syntax error, unrecognized expression: input[id=02620-br-FEBI BILSTEIN].to-cart
Upvotes: -1
Views: 118
Reputation: 8101
You've got a couple options in JavaScript, you can contain them in '
instead of "
:
$('input[id="'+id.slice(0,-1)+'-br-'+brand+'"].qnt_to_cart').show();
or you can escape the quotes via \"
:
$("input[id=\""+id.slice(0,-1)+"-br-"+brand+"\"].qnt_to_cart").show();
Upvotes: 1
Reputation: 8544
$('input[id="'+id.slice(0,-1)+'-br-'+brand+'"].qnt_to_cart').show();
Upvotes: 2
Reputation: 4133
use \"
to escape quotes:
$("input[id=\""+id.slice(0,-1)+"-br-"+brand+"\"].qnt_to_cart").show();
Upvotes: 6