input carriage return trigger event

need

You need to enter text in the search box and press Enter to trigger the search event

accomplish

page code

 <div class="index-search"> <input type="text" name="indexSearch" class="inp" value="<s:property value="front.key"/>" onkeydown="tab(event)" placeholder="Search in this store" id="ssubmitStore"> <img class="icon icon-search" src="/images/djimart-supplier-home/icon_search1.png"> </div>

Effect

When we enter characters in the text box above, press Enter to achieve automatic search

We need to introduce jquery and write the following functional code

The core lies in e.keyCode=13, then we press Enter

Realize 1

 $("#ssubmitStore").keydown(function(e) { if (e.keyCode == 13) { seachStore(); //调用搜索店内商品信息

The post input triggering a carriage return event first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/9125
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment