The following is my code. Without passing value working well.
function add(name) {
alert(name);
}
<button type="button" id="button" class="btn btn-success" onclick="add("Aftab");">
Send
</button>
You have added in this way value to function in this way which is wrong. The issue is due to double quotes.
onclick="add("Aftab");"
Use this
onclick="add('Aftab');"
or
onclick='add("Aftab");'
function add(name) {
alert(name);
}
<button type="button" id="button" class="btn btn-success" onclick="add('Aftab');">
Send
</button>
onclick="add('Aftab');"- or better yet, an unobtrusive event handler instead of the 90s relic that is theon*event attributes.