54
rated 0 times
[
58]
[
4]
/ answers: 1 / hits: 72386
/ 11 Years ago, wed, october 16, 2013, 12:00:00
How do I pass a parameter to a javascript function with '
included
var name =Lauren O'Donald;
var htmlAnch='<a onclick=javascript:selectEmployee(1100,'+name+');return false;
href=javascript:void(0);>O'Donald, Lauren</a>';
$(document).append($(htmlAnch));
The javascript function is not executing since the name 'Lauren O'Donald'
contains single quote.
How can I add a parameter with '
and prepare dynamic html to make it work?
Here is the dynamic code to generate
var rows = new StringBuffer();
$(data).each(function(index) {
rows.append(String.format('<tr><td><a href=No.aspx
onclick=javascript:selectEmployee({3},{1} {2});return
false;>{0}</a></td></tr>',
String.format({0}, {1}, this.Surname, this.FirstName),
this.Surname,
this.FirstName,
this.Id
));
});
More From » jquery