javascript - .show() 在 'display :block' 之后不起作用

标签 javascript jquery html

附件是我的 javascript 和 html。 在 Debug模式下,我可以确认“display: none”更改为“display :block” 但我没有看到 popupEventForm 表单打开。 有什么想法吗? 谢谢,彼得

function ShowEventPopup(date) {
  debugger;
  ClearPopupFormValues();
  $('#popupEventForm').show();
  $('#eventTitle').focus();
}
<div class="container">
  <div id='calendar' style="width:65%"></div>
</div>


<div id="popupEventForm" class="modal hide" style="display: none;">
  <div class="modal-header">
    <h3>Add new event</h3>
  </div>
  <div class="modal-body">
    <form id="EventForm" class="well">
      <input type="hidden" id="eventID">
      <label>Event title</label>
      
      <input type="text" id="eventTitle" placeholder="Title here"><br />
      <label>Scheduled date</label>
      
      <input type="text" id="eventDate"><br />
      <label>Scheduled time</label>
      
      <input type="text" id="eventTime"><br />
      <label>Appointment length (minutes)</label>
      
      <input type="text" id="eventDuration" placeholder="15"><br />
    </form>
  </div>
  <div class="modal-footer">
    <button type="button" id="btnPopupCancel" data-dismiss="modal" class="btn">Cancel</button>
    <button type="button" id="btnPopupSave" data-dismiss="modal" class="btn btn-primary">Save event</button>
  </div>
</div>

最佳答案

您还包含了引导隐藏类..

<div id="popupEventForm" class="modal hide" style="display: none;">

将你的js更改为:

function ShowEventPopup(date) {
        debugger;
        ClearPopupFormValues();
        $('#popupEventForm').show().removeClass('hide');
        $('#eventTitle').focus();
    }

关于javascript - .show() 在 'display :block' 之后不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43738832/

相关文章:

javascript - 设置 ctrl + keydown 事件监听器时出现问题(未检测到)

html - 无法使图像填满背景并在链接悬停时保持纵横比

html - 带分区的垂直 div

html - 如何在sql这个例子中获取节点a和img?

javascript - Object.keys 但不按顺序 JS/TS

javascript - 单击事件的重复数据并使用ajax提交表单

javascript - 使用 JavaScript 显示随机数量的元素

javascript - jquery ui 对话框可在整个对话框上拖动,而不仅仅是标题

javascript - jQuery 追加在下一条语句之前没有完成?

javascript - 如何使用 JQuery 相互检查两个输入 [文本] 值?