<form id="sendform" action="<?php echo home_url(); ?>/" method="get">
<input class="sidesearch" type="text" name="s" id=search">
</form>
<input class="myclass" placeholder="Поиск" type="text" value="" name="myname" id="srch">
<button type="submit" value=""></button>
<input class="myclass" placeholder="Поиск" type="text" value="" name="s" id="srch">
<button type="submit" value=""></button>
<form>
<input class="myclass" placeholder="Поиск" type="text" value="" name="s" id="myid">
<button type="submit" value=""></button>
<form>
<input class="myclass" placeholder="Поиск" type="text" value="" name="s" id="myid">
<button type="submit" value=""></button>
<input class="myclass" placeholder="Поиск" type="text" value="" name="myname" id="srch">
<button type="submit" value=""></button>
jQuery(document).ready(function($){
$('.myclass').keyup(function(eventObject){
console.log("!")
var searchTerm = $(this).val();
if(searchTerm.length > 2){
if(eventObject.keyCode == 13){
$("#srch").val();
$("#sendform").submit();
return;
}
$.ajax({
url : '/wp-admin/admin-ajax.php',
type: 'POST',
data:{
'action':'',
'term' :searchTerm
},
success:function(result){
} });
} });
});
<form id="sendform" action="<?php echo home_url(); ?>/" method="get">
<input class="sidesearch" type="text" name="myname" id=myid">
</form>
<input class="myclass" placeholder="Поиск" type="text" value="" name="myname" id="myid">
<button type="submit" value=""></button>
if(eventObject.keyCode == 13){
$("#sendform").submit();
return;
}
<input class="myclass" placeholder="Поиск" type="text" value="" name="myname" id="myid">
<button type="submit" value=""></button>
<input class="myclass" placeholder="Поиск" type="text" value="" name="myname" id="myid">
<button type="submit" value=""></button>
jQuery(document).ready(function($){
$('.my-class').keypress(function(eventObject){
var searchTerm = $(this).val();
if(searchTerm.length > 2){
$.ajax({
url : '/wp-admin/admin-ajax.php',
type: 'POST',
data:{
'action':'',
'term' :searchTerm
},
success:function(result){
} });
} });
$(".my-class").keypress(function(e) {
var searchTerm = $(this).val();
if(searchTerm.length > 2 && e.keyCode == 13){
$("#sendform").submit();
}
});
});
<form id="sendform" action="<?php echo home_url(); ?>/" method="get">
<input class="sidesearch" type="text" name="myname" id=myid">
</form>
jQuery(document).ready(function($){
$('.my-class').keypress(function(eventObject){
var searchTerm = $(this).val();
if(searchTerm.length > 2){
$.ajax({
url : '/wp-admin/admin-ajax.php',
type: 'POST',
data:{
'action':'',
'term' :searchTerm
},
success:function(result){
} });
} });
$(".my-class").keypress(function(e) {
var searchTerm = $(this).val();
if(searchTerm.length > 2 && e.keyCode == 13){
$("#sendform").submit();
}
});
});
<form id="sendform" action="<?php echo home_url(); ?>/" method="get">
<input class="sidesearch" type="text" name="myname" id=myid">
</form>
<input class="myclass" placeholder="Поиск" type="text" value="" name="myname" id="myid">
<button type="submit" value=""></button>
jQuery(document).ready(function($){
$('.myclass').keypress(function(eventObject){
var searchTerm = $(this).val();
if(searchTerm.length > 2){
$.ajax({
url : '/wp-admin/admin-ajax.php',
type: 'POST',
data:{
'action':'',
'term' :searchTerm
},
});
});
<form>
<input class="myclass" placeholder="Поиск" type="text" value="" name="myname" id="myid">
<button type="submit" value=""></button>
<form>
<input class="myclass" placeholder="Поиск" type="text" value="" name="myname" id="myid">
<button type="submit" value=""></button>
jQuery(document).ready(function($){
$('.myclass').keypress(function(eventObject){
var searchTerm = $(this).val();
if(searchTerm.length > 2){
$.ajax({
url : '/wp-admin/admin-ajax.php',
type: 'POST',
data:{
'action':'',
'term' :searchTerm
},
});
});
<form>
<input class="myclass" placeholder="Поиск" type="text" value="" name="myname" id="myid">
<button type="submit" value=""></button>
<form>
jQuery(document).ready(function($){
$('.myclass').on("keypress", function(eventObject){
var searchTerm = $(this).val();
if(searchTerm.length > 2){
$.ajax({
url : '/wp-admin/admin-ajax.php',
type: 'POST',
data:{
'action':'',
'term' :searchTerm
},
});
});
var postForm = {
'name' : $('#name').val(),
'mail' : $('#mail').val(),
'phone' : $('#phone').val(),
'source' : $('#source').val(),
'medium' : $('#medium').val(),
'campaign' : $('#campaign').val(),
'content' : $('#content').val(),
'term' : $('#term').val()
};
jQuery(document).ready(function($){
$('.myclass').keypress(function(eventObject){
var searchTerm = $(this).val();
if(searchTerm.length > 2){
$.ajax({
url : '/wp-admin/admin-ajax.php',
type: 'POST',
data:{
'action':'',
'term' :searchTerm
},
});
});
jQuery(document).ready(function($){
$('.myclass').keypress(function(eventObject){
var searchTerm = $(this).val();
if(searchTerm.length > 2){
$.ajax({
url : '/wp-admin/admin-ajax.php',
type: 'POST',
data:{
'action':'',
'term' :searchTerm
},
});
});
<input id="myid" value="" type="text" name="myname" placeholder="Я ищу...">
<a class="search_go" onclick="myfunction();"></a>
$('#myid').on("keypress", function (e) {
if ($('#myid').val().length>0 && e.keyCode == 13) {
myfunction();
return false;
}
Для того, чтобы вызвать url : '/wp-admin/admin-ajax.php', который ищет в БД статьи и выводит их в input без перезагрузки самой страницы