Dead Programmer
Dead Programmer

Reputation: 12575

jquery selector on textarea and textbox

I have a div with ID as MQ , i have to get the values of textbox and textareas within this div id MQ using JQuery foreach . i have tried following , but no results.

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

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

kindly let me know your suggestions.

Upvotes: 3

Views: 17920

Answers (2)

Justin Ethier
Justin Ethier

Reputation: 134167

Try this, basically it will find text and textarea attributes within the #MQ div:

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

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

Upvotes: 0

Ken Redler
Ken Redler

Reputation: 23943

Try something like this:

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

Upvotes: 3

Related Questions