$(document).ready(function(){
var $form = $('#filter'),
$controls = $form.find('input,select,textarea');
// отправка после загрузки страницы
startLoadingAnimation();
$.post("/engine/ajax/filter.php", $("#filter").serialize(), function(response){
setTimeout(function(){$('#dle-content').html(response); stopLoadingAnimation();}, 3000);
});
// отправка по клику на Enter
$controls.on('change', function(){
startLoadingAnimation();
$.post("/engine/ajax/filter.php", $("#filter").serialize(), function(response){
setTimeout(function(){$('#dle-content').html(response); stopLoadingAnimation();}, 3000);
});
});
// или отправка при любом изменении в поле
//$controls.on('keyup', function(){
// startLoadingAnimation();
// $.post("/engine/ajax/filter.php", $("#filter").serialize(), function(response){
// setTimeout(function(){$('#dle-content').html(response); stopLoadingAnimation();}, 3000);
// });
//});
});
<ul>
<li class="block_1"> <h1> </h1> <p> </p> </li>
<li class="block_2"> <h1> </h1> <p> </p> </li>
<li class="block_3"> <h1> </h1> <p> </p> </li>
</ul>
var json_date = {
"dills": {
"1": {
"name": "boock_1",
"time": "15:00",
},
"2": {
"name": "book_2",
"time": "15:00",
},
"3": {
"name": "book_3",
"time": "09:00",
},
"4": {
"name": "book_4",
"time": "05:00",
}
}
}
var ix = 1;
setInterval(function () {
var valName = json_date.dills[ix].name,
obj = json_date.dills,
count = 0;
$.each(obj, function () {
count++;
});
(ix >= count) ? ix = 0 : ix = ix;
$('.block_1').text(valName);
++ix;
}, 1000);
<p></p>
<input class="js-but" type="button" value="my_button" />
var json_date = {
"dills": {
"1": {
"name": "boock_1",
"time": "15:00",
},
"2": {
"name": "book_2",
"time": "15:00",
},
"3": {
"name": "book_3",
"time": "09:00",
},
"4": {
"name": "book_4",
"time": "05:00",
}
}
}
var ix = 1;
$('.js-but').on('click', function () {
var valName = json_date.dills[ix].name;
$('p').text(valName);
++ix;
});
var keyUp = $.Event("keydown", { keyCode: 38 }),
keyDown = $.Event("keydown", { keyCode: 40 });
$(".div-up").trigger(keyUp);
$(".div-down").trigger(keyDown);
var evt = document.createEvent("Event");
evt.initEvent("keyup", true, true);
evt.keyCode = 38;
function a(e) {
alert(e.keyCode);
}
document.onkeyup = a;//функция при нажатии клавиши
document.dispatchEvent(evt);//срабатывание
<div class="cells">
<div class="js-cells-elem" data-cellscount="1">1</div>
<div class="js-cells-elem" data-cellscount="2">2</div>
<div class="js-cells-elem" data-cellscount="3">3</div>
<div class="js-cells-elem" data-cellscount="4">4</div>
<div class="js-cells-elem" data-cellscount="5">5</div>
<div class="js-cells-elem" data-cellscount="6">6</div>
</div>
<input type="text" class="js-hidden-input" style="display:none;"/>
.cells div {
margin: 1px;
border: solid 1px gray;
width: 40%;
float: left;
height: 30px;
}
var myTable = $('.cells'),
cellsElem = myTable.find('.js-cells-elem');
cellsElem.on('click', function () {
var $this = $(this),
myText = $this.text(),
myTextId = $this.data('cellscount'),
myInput = $('.js-hidden-input');
myInput.
val(myText).
show().
attr("data-id", myTextId).
focus();
});
$('.js-hidden-input').on('blur', function () {
var $this = $(this),
myInputId = $this.attr('data-id'),
myCells = $('.js-cells-elem').filter('[data-cellscount="' + myInputId + '"]');
myCells.text($this.val());
$this.hide();
});
var wrapBlocks = $('.newsBlocks'),
elemBlock = wrapBlocks.find('.newsItem'),
count = 0,
advBlock = '<div class="you-adv">Моя реклама </div>';
elemBlock.each(function () {
if (count === 3 || count === 6) {
$(this).after(advBlock);
}
++count;
});