I am using jquery 1.11.1 with Flask/jinja2 templates
While attempting to remove row based on class, I used
$("table#success tr[class=" + sale_id.rowclass +"]").remove();
The "sale_id.rowclass" variable is passed in from my jinja template. When the variable is single valued(eg."n133") the statement works perfectly however when the variable holds a double value eg. "danger n133"
I get:
"Error: Syntax error, unrecognized expression: table#success tr[class=danger n133]"
Any ideas on what I am doing wrong?
SOLVED:
Thanks all posters, I am new to jquery and javascript and you guys taught me a lot.
To be able to delete a row containing class " danger n123" OR containing class "n123", I did the following. Thanks to Kevin Grabher and Grundy I got separate values from sale_id.rowclass by using the .split() function
var clsvalues = sale_id.rowclass.split(" ");
Then
$("table#success tr[class~='" + sale_id.rowclass + "'],[class~='" + clsvalues[1] + "']").remove();
The placement of quotes sent me crazy though. If there are more elegant solutions I would welcome it.
To newbies like me the comma between the indexes allowed for an "or". https://stackoverflow.com/a/2263976/4154955