3

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.

3 Answers 3

4
 $('#myDiv').html('<a onclick="remove_item(' + variantId + ');">Remove</a>');
Sign up to request clarification or add additional context in comments.

Comments

0

use it this way -

 $('#myDiv').html('<a onclick="remove_item('+variantId+');">Remove</a>');

Comments

0
$('#myDiv').html('<a onclick="remove_item('+variantId+');">Remove</a>');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.