Alex Rivera | Logout

JQuery clearing an input text field

Asked 2009-12-08T18:05:02.830
9

I have a question regarding clearing an input text field when a different drop down on teh same page is clicked, the value in the input text field should be cleared. Here is my jQuery ftn. The alert message is shown everytime I select an option from drop down but the field does not get cleared. Any idea what the correct syntax should be:

jQuery(document).ready(function(){

        jQuery("[id$='serialNumForm:noSerialNumProductKey']").change(function () {
            alert("In jquery change ftn!!");
            jQuery("[id$='serialNumForm:inputSN']").value="";
        });     
    });

I have a form Id so I need to prepend the Id to the element id name. the alert displays fine just the value does not change.

Edit
Report

1 Answer

19

You want to use:

jQuery("[id$='serialNumForm:inputSN']").val("");
answered 2009-12-08T18:06:35.590

Your Answer