Problem obtaining an id of an element that is clicked with jquery

1

I have this jquery code, what it does is that it is executed when a link is clicked:

<script>
 var num = 0;
 var texto;


$(document).ready(function(){
  $('body').on('click', '#accordion a', function(){
      num = $(this).attr('id');
      temas(num);
  });
});

function temas(num)
{    
    $("#collapse" + num).on("hide.bs.collapse", function(){
     $(".enlace" + num).html("<span class='fa fa-toggle-down'></span> <a class='card-link' data-toggle='collapse' data-target='#collapse" + num + "'  href='#collapse" + num + '"> " + texto + "</a>");
    });

    $("#collapse" + num).on("show.bs.collapse", function(){
     $(".enlace" + num).html("<span class='fa fa-toggle-up'></span> <a class='card-link' data-toggle='collapse' data-target='#collapse" + num + "' href='#collapse" + num + "'"> " + texto + "</a>");
    });
}
</script>

Those links have an id and I get it by clicking on one of them, when I click on a link for the first time if it gets the id but when I click on that same link more than once it marks me indefinitely.

Why is that happening?

    
asked by 15.12.2017 в 21:35
source

1 answer

1

try this code:

 $("#embedcode").html('<iframe src="embed.php?answerid=' + answerid + comments + '" width="550" height="' + $('#embed input[name="size"]').val() + '" frameborder="0"></iframe>');
as in the next one we are using Jquery and selecting the embedcode ID and with. html we are adding a frame to the element that we select, this code can be implemented in your problem.

the code is of the following question: stackoverflow english

    
answered by 15.12.2017 в 22:30