0

I have a page that contains multiple textarea elements. These textareas and the IDs are generated dynamically when originally rendered to the screen.

I know that the selector for the textarea have to be identical.

I can loop through my original data that I used to generate the elements to create a variable that contains the actual id of the textarea. But when I tried to do that I was getting an error.

This was my attempt:

for (i=0;i<=#.myglobals.result.length-1;i++){
var itemName = $.myglobals.result[i].id;
alert($('textarea#'+itemName).val());
}

What I ultimately want is to capture if the textarea has information in it and display
the information if it does.

Please let me know.

Thanks!

3 Answers 3

3

Try this:

$("textarea").each( function() { alert($(this).attr("id")); } );

This finds all textareas on the screen and shows their id in a popup.

Sign up to request clarification or add additional context in comments.

Comments

1

Like this?

$("textarea").each( 
    function(idx, item) { 
        var value = $(item).val();
        if (value) alert(value);
    } 
);

1 Comment

Both answers worked, however, this one did what I needed it to do!
0

Please try this code, hope this will help.

var thought = '';
jQuery("textarea.feedback_msg").each(function() {
    thought += $(this).val();
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.