print variable Java script inside HTML

1

How do I print the various click inside the Html

<script type="text/javascript">
   $(".j_requerimento").click(function(){
     var click = 1;
     $(".j_label_requerimento").append("<span>IMPRIMIR AQUI A VARIAVEL CLICK</span>");});
  </script>
    
asked by anonymous 11.06.2018 / 00:16

1 answer

1

For what you wrote, just make a small change:

<script type="text/javascript">
    $(".j_requerimento").click(function(){
     var click = 1;
     $(".j_label_requerimento").append('<span>${click}</span>');});
</script>

In this case, we use the ES6 Template Strings . However, this is not supported in all browsers. So another option is to use:

<script type="text/javascript">
    $(".j_requerimento").click(function(){
     var click = 1;
     $(".j_label_requerimento").append("<span>" + click + "</span>");});
</script>
    
11.06.2018 / 00:35