How can I add a param to the removeSound function in this JavaScript code?
I cannot get it to work.
var param = "111";
coder = '<a href="javascript:;" onClick="javascript: removeSound(' + param + ');" >Delete</a>'
Update
I do not know why code = was removed! This is needed to explain the problem context.
I just want to add a proper double quoting escape method to the answers as none showed a correct way to escape double quotes inside of an
onClickattribute.In HTML it is not sufficient to use only a backslash when escaping a JavaScript double quote. You need the proper HTML entity which is
"This is a live example:
However for readability I would recommend using Antony Scott’s way by using single quotes.
To add the param as a variable from whatever script your HTML is generated in you should do this:
The other possible way should be: