


A sentence of code based on JQuery to implement simple filtering of tables_jquery
效果图:
代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JqueryTableFilter.aspx.cs" Inherits="JqueryTableFilter" %>
JQuery代码就:
$(function() {
$("#Text1").keyup(function() {
var filterText = $(this).val();
$("#<%=GridView1.ClientID %> tr").not(":first").hide().filter(":contains('" filterText "')").show();;
}).keyup();
});
里面最重要的就是JQuery的选择器:
1:$("#<%=GridView1.ClientID %> tr")选择表格的所有行;
2:not(":first"):除去第一行表头行;
3:filter(":contains('" filterText "')"):从上面所选择的行里面筛选出行文本中包含filterText 的行显示出来;
4:最后加一句keyup()是为了在提交后重新触发keyup事件。(但是在这里没有作用因为我用的客户端控件没有ViewState
若是服务器端控件就会看见他的作用)。
JQuery的选择器的强大之处,让我们能救这么简单的实现客户端的简单筛选。最后加一句关于表格筛选有JQuery插件提供
给我们选择, 但是这种简单的功能,我不会去选择加入一个JavaScript文件库,呵呵。
作者:破 浪

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

Excel is often used to process data in daily office work, and it is often necessary to use the "filter" function. When we choose to perform "filtering" in Excel, we can only filter up to two conditions for the same column. So, do you know how to filter more than 3 keywords at the same time in Excel? Next, let me demonstrate it to you. The first method is to gradually add the conditions to the filter. If you want to filter out three qualifying details at the same time, you first need to filter out one of them step by step. At the beginning, you can first filter out employees with the surname "Wang" based on the conditions. Then click [OK], and then check [Add current selection to filter] in the filter results. The steps are as follows. Similarly, perform filtering separately again

Excel is a frequently used office software. Many users record various data in the table, but the table clearly contains data and is blank when filtering. Regarding this problem, many users don’t know how to solve it. It doesn’t matter. , the content of this software tutorial is to provide answers to the majority of users. Users in need are welcome to check out the solutions. What should I do if there is data in the Excel table but the blanks are filtered? The first reason is that the table contains blank rows. We want to filter all people with the surname "Li", but we can see that the correct results are not filtered out because the table contains blank rows. How to deal with this situation? Solution: Step 1: Select all content and then filter. Press c

When it comes to filtering duplicate content, the first thing you may think of is filtering numerical values in Excel. In fact, in Word, we can also filter duplicate text in documents. When you are not sure whether you have typed a word incorrectly, you can use the filter to take a look. This step is very convenient. The editor below will lead you to learn how to filter duplicate content in Word. Friends who want to learn, come and study hard! 1. First, we open the word document we want to filter on the computer, as shown in the figure below. 2. Then, we select the text we want to find, as shown by the red arrow in the picture below. 3. Press [ctrl+H] on the keyboard to bring up the find and replace command. The red arrow in the figure below points to the

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

When using WPS tables, we sometimes list all types of data in a table. If necessary, we have to select the data that meets the requirements for application. Selecting bit by bit greatly reduces work efficiency. If you can It is much more convenient to use some software functions to make selections. The wps filtering function can realize this operation. Let’s take a look at the operation sharing below. 1. First open the data that needs to be filtered on the computer (as shown below) 2. First select the table header and click "Start" (as shown below). 3. Then click “Filter” (as shown below). 4. Then you will find an inverted triangle behind the table header. Click on the inverted triangle behind "Math" (as shown below). 5. Then the filtering options will pop up, such as clicking "Number Filter"

In daily life, I find that the Excel table cannot be filtered, what should I do? Excel is one of the most commonly used data processing tools, helping users to complete data entry and organization simply and quickly. In order to allow users to use Excel smoothly, let's take a look at the solutions to the problem that Excel tables cannot be filtered. 1. First open the Excel document and click the [View] option in the menu. 2. Click the [Freeze Window] option in the toolbar. 3. Then in the options that open, cancel the freeze setting. 4. You can re-screen after canceling.

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <
