Reputation: 1229
this is probably very easy but I can't figure it out :)
$('#myDiv').html('<a onclick="remove_item(variantId);">Remove</a>');
variantId is a JS variable so I need to pass it's value in the code above.
Upvotes: 3
Views: 7623
Reputation: 33
$('#myDiv').html('<a onclick="remove_item('+variantId+');">Remove</a>');
Upvotes: 0
Reputation: 5405
use it this way -
$('#myDiv').html('<a onclick="remove_item('+variantId+');">Remove</a>');
Upvotes: 0
Reputation: 75588
$('#myDiv').html('<a onclick="remove_item(' + variantId + ');">Remove</a>');
Upvotes: 4