jQuery : firefox and chrome onchange textarea update issue

Today I was doing some code in which I need to update the TextArea text onclick of a list option. I noticed It was working fine in IE all the time but inside Firefox and Chrome it works for first time but next time don’t update the content.

I was using below code

function callMe(){
        var optionValue=$(‘#serviceNm :selected’).attr(‘nits’);
        $(“#serviceRqstNm”).text(”);
        $(“#serviceRqstNm”).text(optionValue);
    }

Later searching the jQuery documentation found that .text works but .val() is arguably more correct one to use. I changed the code to below and it worked fine in all the browsers =).

function callMe(){
        var optionValue=$(‘#serviceNm :selected’).attr(‘nits’);
        $(“#serviceRqstNm”).val(”);
        $(“#serviceRqstNm”).val(optionValue);
    }

About nitingautam

I am Tech Lead (Java/J2EE/ExtJs) with a MNC located @ Gurgaon.
This entry was posted in jQuery. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *