javascript - Uncaught SyntaxError passing multiple values to function -


i trying call function, running struggles escaping values , passing properly. 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 keep getting uncaught syntaxerror: unexpected identifier.

however, if pass 'selectdone(this," + title_id + ");... works, if try , pass 3 raises error.

note: there spaces in status_type variable (multiple classes).

to repeat myself last question:

$(this).html($("<select/>", {   id: 'sel',   change: function() {     selectdone(this, title_id, status_type);   } }).append($("<option/>", { text: "ns" }))); 

also, "class", it'd better use ".prop()":

var status_type = $(this).prop('classname'); 

it's "classname" property. post jquery 1.6, it's pretty rare you'd want ".attr()" , not ".prop()".


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -