jquery has input events. jquery implements the real-time input trigger event code of the input input box is "$('#productName').bind('input propertychange', function() {...}".
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:
//绑定商品名称联想 $('#productName').bind('input propertychange', function() {searchProductClassbyName();});
The code is as follows:
searchProductClassbyName is the method called after triggering ;
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'); });
(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:
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!

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

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

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

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

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

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

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

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


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

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.
