The editor below will share with you an implementation method based on input dynamic fuzzy query. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor and take a look.
When I used jQuery to implement dynamic fuzzy query recently, I searched for a long time but could not find a dynamic fuzzy query method as easy to use as the watch attribute of Vue.js. Let me share the pitfalls encountered so far and several ways to implement dynamic query.
1.jQuery’s change() method.
This method will only trigger the event when the focus of the input box is lost. It feels a bit useless. It may also be that I am not fully familiar with this method. I hope someone understands it. Can you share some tips on how to use it?
<input type="text" id="n3"/> var $n3=$("#n3);//定位到input框 $n3.change(function(){ this.query_search($n3.val());//query_search为模糊查询的方法 })
The change() function is used to bind a handler function to the change event of each matching element. This function can also be used to trigger change events. Additionally, you can pass additional data to the event handler. The change event is triggered when the text content or options are changed. This event only applies to and
2. Monitor JQuery's keyup or keydown event
This method can monitor the trigger event of each key and bind the fuzzy query method to Targeting the response event, each click will trigger a fuzzy query event, but this will greatly increase the pressure on the database. If there are many people operating and there is no cache, the database will explode in minutes.
<input type="text" id="#n3"/> var $n3=$("#n3");//定位到input框 $n3.keyup(function(){ this.query_search($n3.prop("value"));//query_search为模糊查询的方法 })
3. Use the watch attribute observer method of Vue.js.
This method can dynamically observe the changes in attributes in the input box. As long as the value of the input box changes, the corresponding method will be called dynamically.
##Worth it in the end What I said is that there are three ways to get the value in the input text box.
1. Get it through attr("value"). This method can only obtain the default one. In other words, the value originally defined in your CSS code will be the same value when the page is displayed for the first time, and this value will not change. 2. Obtain through prop("value"). This method can get the default value, as well as the changed or value, as long as you change it, you can get it. 3. Obtain through val(). This feels similar to prop("value"). 4. You can also use Vue.js's v-model binding to get it, so that's 4 methods. The above is what I compiled for everyone. I hope it will be helpful to everyone in the future. Related articles:About null and false values in JavaScript
BUGs encountered in JavaScript
How to implement page jump and value transfer in WeChat mini program
How to manage CSS and other resources in webpack and SPA
How to transfer data to template in WeChat applet
The above is the detailed content of How to implement dynamic fuzzy query in input. For more information, please follow other related articles on the PHP Chinese website!

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

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

Vue.js是一种轻量级的JavaScript框架,具有易用、高效和灵活的特点,是目前广受欢迎的前端框架之一。在Vue.js中,input框绑定事件是一个十分常见的需求,本文将详细介绍Vue文档中的input框绑定事件。一、基础概念在Vue.js中,input框绑定事件指的是将输入框的值绑定到Vue实例的数据对象中,从而实现输入和响应的双向绑定。在Vue.j

点击input框没有光标的解决办法:1、确认输入框焦点;2、清除浏览器缓存;3、更新浏览器;4、使用JavaScript;5、检查硬件设备;6、检查输入框属性;7、调试JavaScript代码;8、检查页面其他元素;9、考虑浏览器兼容性。

Vue是一个流行的JavaScript前端框架,它的核心是响应式数据绑定和组件系统。在Vue的应用程序中,input框是最常用的UI元素之一。在用户输入文本时,我们希望可以监听回车事件,并且在提交前对输入内容进行验证。本篇文章将介绍Vue文档中的input框回车事件和验证函数使用方法。一、Vue中input框回车事件在Vue中监听input框的回车事件非常简

jquery中input是选择器选取表单元素,其作用是:1、input用于搜集用户信息,根据不同的type属性值,输入字段拥有很多种形式,输入字段可以是文本字段、复选框、掩码后的文本控件、单选按钮、按钮等等;2、input标签可定义输入域的开始,在其中用户可输入数据;3、使用input标签来进行定义,其中包括文本字段、多选列表、可单击的图像和提交按钮等。

html5 input禁止输入的实现方法:1、通过readonly规定输入字段为只读可复制;2、通过disabled实现被禁用的input元素可复制,但不能接收焦点;3、通过控制input的max length为0实现;4、通过“οnfοcus="this.blur();"”实现不能输入文本即可。

Razer offers an extensive range of gaming accessories. The manufacturer is now expanding this range with the Razer DeathAdder V3 HyperSpeed.This is a lightweight and ergonomic mouse that can be used wirelessly, offering high freedom and minimal hindr


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

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools
