Answer the question
In order to leave comments, you need to log in
How to put a value in a hidden input when clicking on an element on the page?
Now I'll try to explain it more clearly)) For example, there is a tag <p>
, when you click on it, you need to put it in the <input>
values valye="" tag id <p>
. Please tell me how to do this, I'm just starting to learn ajax)
Answer the question
In order to leave comments, you need to log in
Only selectors for input and p should be more specific via id or class so that extraneous elements are not processed
$('p').click(function(){
var id = $(this).attr('id');
$('input').val(id);
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question