To assign a Javascript variable to an HTML value element using jQuery

Asked

Viewed 22 times

-2

I have this code, which is catching the event of click:

$(function(){
  $('.js-editEstoque').on("click", function(){
    var descricao = $(this).attr('data-name-Estoque');
    var id = $(this).attr('data-id-Estoque');
    $('.js-atribuicao-name').append(descricao);
    
  });  
});

This is my HTML:

<pre>
   <input type="text" name="editNameDescription" id='editNameDescription' value="" class="form-control input uppercase js-atribuicao-name" maxlength="40" required>
   <input type="hidden" name="idEstoque" value="" class="js-atribuicao-id">
</pre>

I want to put the two variables above inside each element value HTML, I believe to be something simple but I’m having difficulty.

  • Welcome to [en.so]. I’ve come to realize that you’re creating multiple questions for the same problem, when that won’t actually help you get an answer any faster. Instead, read the guide [Ask] and do a [tour] to learn a little more about the operation of the site and thus increase your chances of getting a good answer.

  • 1

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.