如何在bootstrap中的模态对话框中隐藏元素/标记?

时间:2014-12-13 01:55:47

标签: jquery modal-dialog

我在bootstrap中使用模态对话框时遇到问题。 我有一个按钮,当我点击这个按钮,然后我想在模态对话框上隐藏一个标签( 例如:div class =" radio radio"是隐藏的。我使用jquery但它没有运行。请帮我。非常感谢!

我不明白为什么我的CSS对模态对话没有影响。

 $("#change-status-modal .modal-body div.published").hide();

按钮代码:

 <a href="#" data-toggle="modal" data-target="#change-status-modal" class="btn btn-default change-status">Change Status </a>

模态对话代码:

<div id="change-status-modal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div id="change-status-dialog" class="modal-dialog">
    <div th:fragment="change-status-form" class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Change Status</h4>
      </div>
      <div class="modal-body">
        <p>Select a new status that you want to change.</p>
        <div class="radio published ">
          <input type="radio" name="status"  value="PUBLISHED" /> Published
        </div>
        <div class="radio draft ">
          <input type="radio" name="status" value="DRAFT" checked="checked" /> Draft
        </div>
        <div class="radio scheduled">
          <input type="radio" name="status" value="SCHEDULED" /> Scheduled
        </div>
      </div>
      <div class="modal-footer">
        <button class="btn btn-default" data-dismiss="modal" th:text="#{Cancel}">Cancel</button>
        <button class="btn btn-primary" th:attr="data-action=@{__${ADMIN_PATH}__/articles/change-status}"  >Change</button>
      </div>
    </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

首先要更容易地给出部分,这应该隐藏一些ID。然后您可以轻松访问它们并添加css属性:

<a id="buttonHide" href="#" data-toggle="modal" data-target="#change-status-modal" class="btn btn-default change-status">Change Status </a>

$("#buttonHide").click(function(){$("#myParagraphToHide").css({"display": none})});