I have a jQuery statement
$('.searchDisplay').append('<i class="ion-email" onclick="copyEmail('+data[i].email+')"></i>' );
Here if I click this icon then this function copyEmail() is called which takes a string as an argument and adds it to the clipboard.
But when I click on the icon I get an error in my console
Uncaught SyntaxError: Invalid or unexpected token
then I tried doing it this way
$('.searchDisplay').append('<i class="ion-email" onclick="copyEmail("'+data[i].email+'")"></i>' );
I got this error
Uncaught SyntaxError: Unexpected token }
The problem is that I'm not able to pass a string in function.
Can someone slove this for me ?