Jquery href attribute not getting disabled

僤鯓⒐⒋嵵緔 提交于 2019-12-25 08:01:19

问题


I can't seem to implement the correct syntax and/or logic to remove an anchor tag upon a condition being met using Jquery. I then want to enable it again upon another condition being met. My current logic is flawed and doesn't work. I need to know if there is a relatively simple workaround; otherwise, I will just use a button, so I can use the disabled state logic I currently have in place. Please provide fiddle if you have solution.

Here is the fiddle - https://jsfiddle.net/carbot3000/yoonn2x1/3/

else if ($(".areaall").children().first().index() == $(".areaall .review:visible").first().index()) {
    $('.prev').css("color","grey");
    $('.prev').attr("disabled",true);
}

$('.next').click(function() {
    $('.prev').show();
    $('.prev').css("color","#31b2ed");
    $('.prev').attr("disabled",false);
    rvwList.slice(start, start + x).hide();
    start += x;
    rvwList.slice(start, start + x).show();
    showHide();
    console.log('size_li is:' + size_li);
    console.log('start is:' + start);
    console.log('start is:' + end);  
});

回答1:


Anchor tags do not have a "disabled" state. You'll have to just unbind the click or change the CSS applied to make it appear disabled... or use button elements rather than anchors...



来源:https://stackoverflow.com/questions/39480825/jquery-href-attribute-not-getting-disabled

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!