M
M
m_xplay_official2019-01-23 08:42:46
AJAX
m_xplay_official, 2019-01-23 08:42:46

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

1 answer(s)
2
2cha.headz, 2019-01-23
@m_xplay_official

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 question

Ask a Question

731 491 924 answers to any question