jQuery search box input content to find whether the code in the table matches
code segment:
function search(){
// Get the value of the search box
var kwds = $("#searchInput").val();
// Get the first list content
var this_one = {};
var real_name = '';
// Define data list
var list = $("#all_list .list_one");
// Define the starting value for search
var true_one = 0;
for (var i = 0; i < list.length; i++) {
This_one = $(list[i]);
Real_name = this_one.text().toString();
// Execute like matching
If(real_name.match(kwds)){
// Process the current result
if(true_one == active){
// Get the width and height of the window
var windows_wdh = $(window).width();
var windows_hgt = $(window).height();
// Get the first coordinate
var x_len = this_one.offset().left;
var y_len = this_one.offset().top;
// Drive the scroll bar to scroll to the specified position
$("html,body").animate({scrollTop:(y_len-windows_hgt/2), scrollLeft:(x_len-windows_wdh/2)},500);
// Mark the currently selected results
This_one.addClass('active');
This_one.removeClass('on');
}else{
// Mark the matching results
This_one.addClass('on');
This_one.removeClass('active');
}
// Accumulate real choices
true_one++;
}else{
This_one.removeClass('on');
} }
}
// Determine whether the search is completed. If the search is completed, start from the first one, otherwise continue to search for the next one
active = active >= true_one-1 ? 0 : active+1;
Return false;
}
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
24 Jun 2016
CSS3 JQUERY page scrolling effects code
24 Jun 2016
58 jQuery simulated CSS3 transition page switching effects
06 Jul 2016
jquery waterfall flow LightBox picture box special effects
03 Dec 2024
jQuery $(document).ready and UpdatePanels: A Refined LookWhen utilizing jQuery to apply mouseover effects to elements within an UpdatePanel, the...
13 Nov 2024
jQuery: Dynamically Modifying Text with Mouseover EventsWhen interacting with elements on a web page, adding subtle effects can enhance user...
22 Oct 2024
To replicate hover effects on touch-enabled devices, this article proposes a technique using a combination of CSS and JavaScript. It demonstrates how to add hover effects to elements on touchstart and touchend events using jQuery, and how to style th
24 Jun 2016
CSS3 input box shadow effects and other shadow effects
24 Jun 2016
61 web page special effects that are very fashionable and have great visual effects
23 Oct 2024
jQuery doesn't natively fade background images. This article presents a workaround using hidden tags with absolute positioning and negative z-index to mimic background behavior, allowing for fading effects on background images.
Hot Tools
jQuery2019 Valentine's Day Confession Fireworks Animation Special Effects
A very popular jQuery Valentine's Day confession fireworks animation special effect on Douyin, suitable for programmers and technical geeks to express their love to the girl they love. No matter you choose to be willing or not, you have to agree in the end.
layui responsive animated login interface template
layui responsive animated login interface template
520 Valentine's Day confession web animation special effects
jQuery Valentine's Day Confession Animation, 520 Confession Background Animation
Cool system login page
Cool system login page
HTML5 tape music player-CASSETTE PLAYER
HTML5 tape music player-CASSETTE PLAYER