Reputation: 85
$("<button class='btn btn-success' onclick='commentupload("+foo.id+","+uname+","+name+")' style='margin-top:5px;align:left'>")
This the code of jquery which i am using to generate this button dynamically. i need to pass the 3 argument 1st one is integer so there is no problem with that but the 2nd and the third parameter contains string so it requires ' before and after. But i am unable to implement that.
Please help me with this...
Upvotes: 0
Views: 55
Reputation: 31204
You need to escape the quotes.
$("<button class='btn btn-success' onclick='commentupload(" + foo.id + ", \"" + uname + "\", \"" + name + "\")' style='margin-top:5px; align:left;'>")
Upvotes: 1
Reputation:
you can use this to handle it.
$("<button class='btn btn-success' onclick='commentupload(" + foo.id + ", \"" + uname + "\", \"" + name + "\")' style='margin-top:5px; align:left;'>")
Upvotes: 1