Does jquery have an input event?

藏色散人
Release: 2023-03-21 10:41:05
Original
1691 people have browsed it

jquery has input events. jquery implements the real-time input trigger event code of the input input box is "$('#productName').bind('input propertychange', function() {...}".

Does jquery have an input event?

The operating environment of this tutorial :Windows10 system, jquery3.6 version, Dell G3 computer.

Does jquery have input events?

Yes.

jquery implementation Input input box real-time input trigger event code

The code is as follows:

Copy after login

The code is as follows:

//绑定商品名称联想 
$('#productName').bind('input propertychange', function() {searchProductClassbyName();});
Copy after login

The code is as follows:

searchProductClassbyName is the method called after triggering ;

Does jquery have an input event?

js/jquery The perfect solution for monitoring input box value changes in real time: oninput & onpropertychange

(1) Let’s talk about jquery first. If you use the jQuery library, You only need to bind the oninput and onpropertychange events at the same time. Sample code:

$('#username').bind('input propertychange', function() {
    $('#content').html($(this).val().length + ' characters');
});
Copy after login

(2) For JS native writing, oninput is a standard event of HTML5. For detecting textarea, input:text, The input:password and input:search elements are very useful for content changes through the user interface. They are triggered immediately after the content is modified, unlike the onchange event which needs to lose focus before being triggered. The compatibility of the oninput event in mainstream browsers is as follows:

Does jquery have an input event?

As can be seen from the above table, the oninput event is not supported in versions below IE9. It needs to be replaced by the IE-specific onpropertychange event. This event is used by the user It will be triggered when the interface changes or when the content is directly modified using a script. There are the following situations:

The selected state of the input:checkbox or input:radio element is modified, and the checked attribute changes.

The value of the input:text or textarea element is modified, and the value attribute changes.

The selected item of the select element has been modified, and the selectedIndex attribute has changed.

After listening to the onpropertychange event, you can use the propertyName attribute of the event to get the changed property name.

Collection oninput & onpropertychange The sample code for monitoring input box content changes is as follows:

 
    

Please modify the contents of the text field.
Copy after login

Recommended learning: jQuery video tutorial

The above is the detailed content of Does jquery have an input event?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!