Home  >  Article  >  Web Front-end  >  How jQuery monitors text box events and handles them accordingly_jquery

How jQuery monitors text box events and handles them accordingly_jquery

WBOY
WBOYOriginal
2016-05-16 16:03:371253browse

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;
}

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

Statement:
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