JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" id="7830" class="openembed">Embed</a>
<a href="#" id="9999" class="openembed">Embed</a>
Embed code:
<div id="#embedcode"></div>
JavaScript
function generateCode(answerid) {
if($('#embed input[name="comments"]:checked').length > 0 == true) {
var comments = "&comments=1";
} else {
var comments = "";
}
$("#embedcode").html('<iframe src="embed.php?answerid=' + answerid + comments + '" width="550" height="' + $('#embed input[name="size"]').val() + '" frameborder="0"></iframe>');
}
$(document).ready(function () {
$('.openembed').click(function (element) {
var answerid = $(this).attr('id');
alert(answerid);
generateCode(answerid);
$('#box').show();
return false;
});
$('#embed').click(function (e) {
e.stopPropagation()
});
$(document).click(function () {
$('#box').hide()
});
});