Home > Web Front-end > JS Tutorial > body text

How jQuery monitors text box events and handles them accordingly_jquery

WBOY
Release: 2016-05-16 16:03:37
Original
1258 people have browsed it

The example in this article describes how jQuery monitors text box events and handles them accordingly. Share it with everyone for your reference. The details are as follows:

//事情委托
$(document)
 .on('input propertychange', '#query', function(){
  var input = $(this).val();
  show(input);
 });
 var show = function(txt){
  var info = '监听:<b>' + txt + '</b><br /><br />'
  + '相关搜索:<br />' + showTags(txt);
  $('.info').html(info);
 }
 var showTags = function(txt){
  var tag = '';
  if(txt.length){
   for (var i = 0; i < 3; i++) {
    tag += '<span class="tag">'+txt+'相关'+i+'</span>';
   };
  }
  return tag;
}
Copy after login

I hope this article will be helpful to everyone’s jQuery programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template