简体   繁体   English

jQuery禁用上一个下一个按钮

[英]jQuery disable previous next buttons

On a blogger blog I have two arrow shapes(div with border) with id left1 and right1 for navigation. 在一个博客博客中,我有两个箭头形状(带有边框的div),分别具有ID left1和right1用于导航。

I am using jQuery on click to simulate click on 'previous post' and 'newer post'with id prevorig and neworig respectively. 我在单击时使用jQuery模拟分别使用ID prevorig和neworig的“上一个帖子”和“较新的帖子”的单击。

jQuery(document).ready(function () {
    jQuery('#left1').on('click', function () {
        jQuery('#prevorig')[0].click();
    });
});

Previous post has id prevorig and next post has id nextorig. 上一篇文章的ID为prevorig,下一篇文章的ID为nextorig。

<ul class='pager'>
    <b:if cond='data:newerPageUrl'>
        <li class='next'>
            <a class='blog-pager-newer-link' id='neworig' expr:href='data:newerPageUrl' expr:id='data:widget.instanceId + &quot;_blog-pager-newer-link&quot;' expr:title='data:newerPageTitle'><data:newerPageTitle/></a>
        </li>
    </b:if>
    <b:if cond='data:olderPageUrl'>
        <li class='previous'>
            <a class='blog-pager-older-link' id='prevorig' expr:href='data:olderPageUrl' expr:id='data:widget.instanceId + &quot;_blog-pager-older-link&quot;' expr:title='data:olderPageTitle'><data:olderPageTitle/></a>
        </li>
    </b:if>
</ul>

However I am not able to hide these two elements with id left1 and right1 when it reaches the latest or the first post. 但是,当到达最新或第一篇文章时,我无法隐藏ID为left1和right1的这两个元素。 In above case the actual links having id prevorig and neworig are not displayed. 在上述情况下,不显示具有id prevorig和neworig的实际链接。 How can I do it. 我该怎么做。 Thanks 谢谢

Why dont you try 你为什么不尝试

if ($( "#left1" ).length){
    if  ($("#left1").attr('href') == '') { 
     $(this).hide(); 
    }
}

Use the same for blog-pager-older-link 对blog-pager-older-link使用相同的

if .hide() is not working due your jquery version try 如果.hide()由于您的jquery版本不起作用,请尝试

$(this).css('display','none');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM