jquery - 禁用重复 div 内的所有按钮

标签 jquery jquery-templates

所以我有一个 Jquery 模板,可以向用户显示多个结果,结果的底部是一个 div,我用它来存储一些按钮。

现在,根据记录的状态,我想隐藏 e div 中的所有按钮,但由于某种原因,以下命令不执行任何操作:

$('#violationFooter').find('input,button').prop('disabled', true);

我尝试了其他几种设置,以下隐藏父 div

   $('#violationResults').hide();

但这也没有任何作用

   $('#violationResults #violationFooter').hide();

我迷茫了

编辑

   <script id="violationtmpl" type="text/x-jquery-tmpl">
            <div class="row user-infos ${MessageId}">
                <div class="col-xs-12 col-sm-12 col-md-10 col-lg-12">
                    <div class="panel panel-danger">
                        <div class="panel-heading">
                            <h3 class="panel-title">Violation</h3>
                        </div>
                        <div  class="panel-body">
                            <div class="row-fluid">
                                <div class="col-md-9 col-lg-9 hidden-xs hidden-sm">
                                    <table class="table table-user-information" id="scrollable" style="height: 200px;">
                                        <tbody>

                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div id="violationFooter" class="panel-footer">
                            <button class="btn  btn-success btn-xs" type="button" data-toggle="tooltip" data-original-title="Good guy?" onclick="" ><i class="fa fa-user-md"></i></button>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </script> 

*编辑*

这是填充模板的调用

function GetViolations(messageId) {

            $.ajax({
                type: "POST",
                url: "Default.aspx/GetViolationMessages",
                cache: false,
                data: JSON.stringify({ messageId: messageId }),
                contentType: "application/json; charset-utf-8",
                dataType: "json",
                error:
                    function(xhr) {

                        var contentType = xhr.getResponseHeader("Content-Type");
                        if (xhr.status === 401 && contentType.toLowerCase().indexOf("text/html") >= 0) {
                            window.location.reload();
                        }
                    },
                success: function(msg) {
                    // Need to work out a way of refreshing the screen

                    $.each(msg.d, function(index, item) {

                        $('#violationtmpl').tmpl(item).appendTo('#violationResults');

                    });


                    var panels = $('.user-infos');
                    var panelsButton = $('.dropdown-user');
                    panels.hide();

                    //Click dropdown
                    panelsButton.click(function() {
                        //get data-for attribute
                        var dataFor = $(this).attr('data-for');
                        var idFor = $(dataFor);

                        //current button
                        var currentButton = $(this);
                        idFor.slideToggle(400, function() {
                            //Completed slidetoggle
                            if (idFor.is(':visible')) {
                                currentButton.html('<i class="glyphicon glyphicon-chevron-up text-muted"></i>');
                            } else {
                                currentButton.html('<i class="glyphicon glyphicon-chevron-down text-muted"></i>');
                            }
                        });
                    });

                    $('[data-toggle="tooltip"]').tooltip();
                }
            });
        };

编辑

渲染的 HTML 图像

enter image description here

最佳答案

试试这个:

$('#violationFooter button').hide()

或更好

$('.panel-footer button').hide()

关于jquery - 禁用重复 div 内的所有按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22527989/

相关文章:

jquery - 表行/数据上的第 n 个 child (偶数)

javascript - 当选项卡为空时隐藏选项卡

javascript - 超出视口(viewport)时停止 slider 滚动?

javascript - Jquery 模板 if xx && if yy

jquery - JavaScript "Expected ' ]'"

javascript - 使用 jQuery 模板访问多维 JSON

javascript - 使用下拉列表动态更改 PHP Mysql 查询

jquery - 使用 ASP.NET 和 MVC 提交表单以执行正确操作

jQuery template() 用于将 URL 放入图像的 src= 属性中

jquery tmpl 默认选项