$('#productName ').bind('input propertychange', function() {...}"."/> $('#productName ').bind('input propertychange', function() {...}".">
search
HomeWeb Front-endFront-end Q&ADoes jquery have an input event?
Does jquery have an input event?Mar 21, 2023 am 10:41 AM
jqueryinput

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:

<input id="productName" name="productName" class="wid10" type="text" value="" />

The code is as follows:

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

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:

$(&#39;#username&#39;).bind(&#39;input propertychange&#39;, function() {
    $(&#39;#content&#39;).html($(this).val().length + &#39; characters&#39;);
});

(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:

 <head>
    <script type="text/javascript">
    // Firefox, Google Chrome, Opera, Safari, Internet Explorer from version 9
        function OnInput (event) {
            alert ("The new content: " + event.target.value);
        }
    // Internet Explorer
        function OnPropChanged (event) {
            if (event.propertyName.toLowerCase () == "value") {
                alert ("The new content: " + event.srcElement.value);
            }
        }
    </script>
</head>
<body>
    Please modify the contents of the text field.
    <input type="text" oninput="OnInput (event)" onpropertychange="OnPropChanged (event)"
     value="Text field" />
</body>

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!

Statement
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
jquery实现多少秒后隐藏图片jquery实现多少秒后隐藏图片Apr 20, 2022 pm 05:33 PM

实现方法:1、用“$("img").delay(毫秒数).fadeOut()”语句,delay()设置延迟秒数;2、用“setTimeout(function(){ $("img").hide(); },毫秒值);”语句,通过定时器来延迟。

jquery怎么修改min-height样式jquery怎么修改min-height样式Apr 20, 2022 pm 12:19 PM

修改方法:1、用css()设置新样式,语法“$(元素).css("min-height","新值")”;2、用attr(),通过设置style属性来添加新样式,语法“$(元素).attr("style","min-height:新值")”。

axios与jquery的区别是什么axios与jquery的区别是什么Apr 20, 2022 pm 06:18 PM

区别:1、axios是一个异步请求框架,用于封装底层的XMLHttpRequest,而jquery是一个JavaScript库,只是顺便封装了dom操作;2、axios是基于承诺对象的,可以用承诺对象中的方法,而jquery不基于承诺对象。

vue3怎么封装input组件和统一表单数据vue3怎么封装input组件和统一表单数据May 12, 2023 pm 03:58 PM

准备工作用vuecreateexample创建项目,参数大概如下:用原生input原生的input,主要是value和change,数据在change的时候需要同步。App.tsx如下:import{ref}from&#39;vue&#39;;exportdefault{setup(){//username就是数据constusername=ref(&#39;张三&#39;);//输入框变化的时候,同步数据constonInput=;return()=>({

laravel input隐藏域怎么实现laravel input隐藏域怎么实现Dec 12, 2022 am 10:07 AM

laravel input隐藏域的实现方法:1、找到并打开Blade模板文件;2、在Blade模板中使用method_field方法来创建隐藏域,其创建语法是“{{ method_field('DELETE') }}”。

jquery怎么去掉只读属性jquery怎么去掉只读属性Apr 20, 2022 pm 07:55 PM

去掉方法:1、用“$(selector).removeAttr("readonly")”语句删除readonly属性;2、用“$(selector).attr("readonly",false)”将readonly属性的值设置为false。

jquery on()有几个参数jquery on()有几个参数Apr 21, 2022 am 11:29 AM

on()方法有4个参数:1、第一个参数不可省略,规定要从被选元素添加的一个或多个事件或命名空间;2、第二个参数可省略,规定元素的事件处理程序;3、第三个参数可省略,规定传递到函数的额外数据;4、第四个参数可省略,规定当事件发生时运行的函数。

jquery怎么获取table当前第几行jquery怎么获取table当前第几行Apr 21, 2022 pm 05:38 PM

方法:1、用“$("tr").click(function(){})”给表格行元素绑定点击事件,并设置处理函数;2、在函数中,用“$(this).index()+1”获取点击元素的行数即可。index()获取值从0开始计数,需进行加1处理。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.