I have user-defined function like below, i need to call it while click on search button and as well as by pressing enter button.
<input id="cnc-search" type="text" name="" class="cnc-inputloc" value=""/> // input box
<span class="quick-search" id="quickviewsearch"></span>// search icon
function myFun(){
alert('hi');
}
Tried like below is it correct way.
$(document).ready(funtion(){
$("#quickviewsearch").on('click keypress', myFun);
$('#cnc-search').keypress(function(e){
if(e.which == 13){//Enter key pressed
$('#quickviewsearch').click();
}
});