hide elements with name using jquery

This question already has an answer here:

  • How can I select an element by name with jQuery? 15 answers

  • 我想你错过了你名字的引号:

    <a class="al_ynbtn apv_app" id="approveLeave" name="<%=leave_request_id%>"></a>
    <a class="al_ynbtn can_app" id="rejectLeave" name="<%=leave_request_id%>"></a>
    

    使用jQuery:

    $('a').filter(function(){
        return this.name === '3257';
    }).hide();
    

    render: function() {
        $(this.el).html(this.template(this.model));
        var selectedElem='[name='+self.model.leave_request_id+']';
        //$('[name='3257']').hide(); //Hardcoded name value
        $('[name='' + self.model.leave_request_id + '']').hide();//jQuery cascades so you can call .hide() on the same line
        return this.el;
    }
    
    链接地址: http://www.djcxy.com/p/36262.html

    上一篇: 在特定的表单名称上运行ajax调用

    下一篇: 使用jquery隐藏具有名称的元素