Home > Web Front-end > JS Tutorial > How to implement dynamic fuzzy query in input

How to implement dynamic fuzzy query in input

亚连
Release: 2018-06-21 14:26:59
Original
2767 people have browsed it

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为模糊查询的方法
})
Copy after login

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