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.