Example of change event usage in jQuery, jquerychange
This example describes the change event usage in jQuery. Share it with you for your reference. The specific analysis is as follows:
The change event is triggered when the Matching Element loses focus or its value gets focus and changes.
A complete event process requires not only conditions for triggering events, but also event handlers.
You can bind an event handler to a change event using the change () method. For example:
Copy codeThe Code is as follows: $ ("input"). change (function () {$ ("input" ).css ("backgroundColor", "green ")})
The above code binds the function as an event handler to the change event through the change () method. This function is called when the change event is triggered.
Instance code:
Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Meta name = "author" content = "http://www.bkjia.com/"/>
<Title> helping customers </title>
<Script type = "text/javascript" src = "mytest/jQuery/jquery-1.8.3.js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("Input"). change (function (){
$ ("Input" ).css ("backgroundColor", "green ")
})
})
</Script>
</Head>
<Body>
<Div> <input type = "text" name = "content"/> </div>
<Div> an event is triggered when text in the text box is changed </div>
</Body>
</Html>
I hope this article will help you with jQuery programming.