Jquery selector on textarea and text box

I have a div with the identifier MQ , I need to get the values ​​of the text field and text fields inside this div id MQ using jQuery foreach . I tried to follow but no results.

$('div#MQ :text,textarea').each(function(){

$('div#MQ input[type="text"],textarea).each

kindly tell me your suggestions.

+3
source share
2 answers

Try something like this:

$('#MQ').find('textarea,:text').each( function(){
  var result = $(this).val(); // do something with each element value
});
+3
source

Try it, basically it finds textand textareaattributes in the #MQdiv:

$('text,textarea', "#MQ").each(function(){

For an explanation of this syntax, see jquery-this-syntax-question .

0
source

Source: https://habr.com/ru/post/1790477/


All Articles