Bind a handler function to the change event of each matching element. The change event is triggered when an element loses focus, and also when its value changes after gaining focus.
JqueryBasic syntax:
$("input[type='text']").change( function() { // 这里可以写你想要的验证代码; });
2 When binding a text box
$(function () { $("#txtAssessmentTotal").change(function () { //这里写你想要的验证的代码; }) })
is the specific value of each matching element Event bindingEvent handling function. The
.bind() method is the primary way to attach behavior to a document. All JavaScript event objects, such as focus, mouseover, and resize, can be passed in as the type parameter.
Personal understanding of bind is to bind the event for this control and define an anonymous method for this event to achieve the verification you want;
Jquery basic syntax:
$("#txtAssessmentTotal").bind('click', function() { alert($("#txtAssessmentTotal").val()); });
2 Multiple events: The names of the events are separated by spaces;
$("#txtAssessmentTotal").bind('mouseenter mouseleave', function() { alert($("#txtAssessmentTotal").val()); });
The above is the detailed content of Jquery: Sample code sharing for change event and bind event. For more information, please follow other related articles on the PHP Chinese website!