kamehamehaaaaaa
kamehamehaaaaaa

Reputation: 13

how to add div value to a variable via jquery

So i have a div which is text area. Now I want to take the text generated here and store it to a variable. how do i do that in jquery.

this is my code. i want to use a flag to store one value and then later concatenate it to other value and display.

jQuery("#analysis_selectbox").change(function () {
    Flag = text_area.val

    if (jQuery(this).val() == "1") {
        jQuery("#text_area").val(Flag + "success1");
    } else {
        jQuery("#text_area").val(Flag + "success2");

    }
});
});

Upvotes: 0

Views: 60

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115242

You need to use jQuery("#text_area").val() or jQuery("#text_area")[0].value , because val is neither a valid jQuery or JavaScript selector

jQuery("#analysis_selectbox").change(function(){
    Flag = jQuery("#text_area").val();

    if (jQuery(this).val() == "1") 
    {
    jQuery("#text_area").val(Flag + "success1");
    }
    else {
    jQuery("#text_area").val(Flag + "success2");  

    }
});

Upvotes: 1

Related Questions