js中设置元素a的一些属性

在js中设置元素a的一些常见属性。

如分页按钮组合中的:上一页、下一页、首页、末页

如判断为首页,那么上一页和首页按钮应该是不可点击的,设置如下。

function firstPageEnablePageBtn(isEnable) {
    var firstPage = document.getElementById("firstPage");
    var prePage = document.getElementById("prePage");
    if(isEnable) {
        firstPage.removeAttribute("disabled");
        prePage.removeAttribute("disabled");
        firstPage.setAttribute("href", "#");
        prePage.setAttribute("href", "#");
    } else {
        firstPage.removeAttribute("href");
        prePage.removeAttribute("href");
        firstPage.setAttribute("disabled", "disabled");
        prePage.setAttribute("disabled", "disabled");
    }
}

如判断为末页,那么下一页和末页按钮应该是不可点击的,设置如下。

function lastPageEnablePageBtn(isEnable) {
    var lastPage = document.getElementById("lastPage");
    var nextPage = document.getElementById("nextPage");
    if(isEnable) {
        lastPage.removeAttribute("disabled");
        nextPage.removeAttribute("disabled");
        lastPage.setAttribute("href", "#");
        nextPage.setAttribute("href", "#");
    } else {
        lastPage.removeAttribute("href");
        nextPage.removeAttribute("href");
        lastPage.setAttribute("disabled", "disabled");
        nextPage.setAttribute("disabled", "disabled");
    }
}

js中创建一个a元素

        var refuse = document.createElement("a");
        refuse.setAttribute('data-toggle',"modal" );  //模态框属性
        refuse.setAttribute('data-target',"#myModalRefuse" );  //模态框属性
        refuse.innerText = '拒绝申请';  //a文字显示
        refuse.style.color = "red";   //a文字颜色
        refuse.style.cursor = "pointer";  //鼠标放置在该链接文字上出现手指点击的图标
        refuse.style.textDecoration = "underline"; //出现下划线
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值