Answer the question
In order to leave comments, you need to log in
What is wrong with this page turning code?
<div class='next1'>
<?php previous_post_link('%link', '<img src="#" width="45" height="35" alt="previous" />'); ?>
</div>
<div class='prev1'>
<?php next_post_link('%link', '<img src="#" width="45" height="35" alt="Next" />') ; ?>
</div>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).keypress(function (e){
if(e.keyCode == 37) // left arrow
{
$('.prev1').click();
}
else if(e.keyCode == 39) // right arrow
{
$('.next1').click();
}
});
</script>
Answer the question
In order to leave comments, you need to log in
$('.prev1').click(); –> $('.prev1').trigger('click');
$('.next1').click(); –> $('.next1').trigger('click');
What's wrong - terrible style code;
And, most likely, you need to bind an event to click on the desired elements.
$('.next1').bind('click', function(){
// код
return false;
});
If you are
trying to follow the link in this way, then this will not happen. Take the href attribute and put it in window.location
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question