I am trying to call a function, but am running into some struggles with properly escaping the values and passing it properly. I currently have:
function selectdone(sel, title_id, status_type) {
...
}
$(function() {
$("td.status-updates").click(function() {
if ($(this).find('#sel').length == 0) {
var before = $(this).text();
var title_id = $(this).parent().attr('id');
var status_type = $(this).attr('class');
$(this).html("<select id='sel'
onchange='selectdone(this," + title_id + "," + status_type +");'...
<option>NS</option></select>");
}
});
The error I keep getting from this is Uncaught SyntaxError: Unexpected identifier.
However, if I pass it as 'selectdone(this," + title_id + ");... it works, but if I try and pass three it raises that error.
Note: there are spaces in the status_type variable (multiple classes).
To repeat myself from your last question:
Also, to get the “class”, it’d probably be better to use “.prop()”:
It’s “className” as a property. Post jQuery 1.6, it’s pretty rare that you’d really want “.attr()” and not “.prop()”.