我正在尝试显示按下表格单元格的模态对话框,但不起作用。按钮效果很好,但不在表中。 我的代码如下:
HTML
<div class="col-md-6">
<label class="select margin-bottom-15">
@Html.DropDownList("City", (SelectList)ViewBag.CityList, "- Select City -", new { @class = "form-control"})
/label>
</div>
复制到剪贴板选择 此表以日历形式生成月中的日期。我尝试做的是显示一个模态对话框,其中包含所选日期的任务。 我想:
<table class="clndr-table" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr class="header-days">
<td class="header-day">S</td>
<td class="header-day">M</td>
<td class="header-day">T</td>
<td class="header-day">W</td>
<td class="header-day">T</td>
<td class="header-day">F</td>
<td class="header-day">S</td>
</tr>
</thead>
<tbody>
<tr>
<td class="day past adjacent-month last-month calendar-day-2015-08-30">
<div class="day-contents">30</div>
</td>
<td class="day past adjacent-month last-month calendar-day-2015-08-31">
<div class="day-contents">31</div>
</td>
<td class="day past calendar-day-2015-09-01">
<div class="day-contents" href="#alert" id="alert">1</div>
</td>
<td class="day past calendar-day-2015-09-02">
<div class="day-contents">2</div>
</td>
<td class="day past calendar-day-2015-09-03">
<div class="day-contents">3</div>
</td>
<td class="day past calendar-day-2015-09-04">
<div class="day-contents">4</div>
</td>
<td class="day past calendar-day-2015-09-05">
<div class="day-contents">5</div>
</td>
</tr>
<tr>
<td class="day past calendar-day-2015-09-06">
<div class="day-contents">6</div>
</td>
<td class="day past calendar-day-2015-09-07">
<div class="day-contents">7</div>
</td>
<td class="day past calendar-day-2015-09-08">
<div class="day-contents">8</div>
</td>
<td class="day past calendar-day-2015-09-09">
<div class="day-contents">9</div>
</td>
<td class="day past event calendar-day-2015-09-10">
<div class="day-contents">10</div>
</td>
<td class="day past event calendar-day-2015-09-11">
<div class="day-contents">11</div>
</td>
<td class="day past event calendar-day-2015-09-12">
<div class="day-contents">12</div>
</td>
</tr>
<tr>
<td class="day past event calendar-day-2015-09-13">
<div class="day-contents">13</div>
</td>
<td class="day past event calendar-day-2015-09-14">
<div class="day-contents">14</div>
</td>
<td class="day past calendar-day-2015-09-15">
<div class="day-contents">15</div>
</td>
<td class="day past calendar-day-2015-09-16">
<div class="day-contents">16</div>
</td>
<td class="day past calendar-day-2015-09-17">
<div class="day-contents">17</div>
</td>
<td class="day past calendar-day-2015-09-18">
<div class="day-contents">18</div>
</td>
<td class="day past calendar-day-2015-09-19">
<div class="day-contents">19</div>
</td>
</tr>
<tr>
<td class="day past calendar-day-2015-09-20">
<div class="day-contents">20</div>
</td>
<td class="day past event calendar-day-2015-09-21">
<div class="day-contents">21</div>
</td>
<td class="day past event calendar-day-2015-09-22">
<div class="day-contents">22</div>
</td>
<td class="day past event calendar-day-2015-09-23">
<div class="day-contents">23</div>
</td>
<td class="day past calendar-day-2015-09-24">
<div class="day-contents">24</div>
</td>
<td class="day past calendar-day-2015-09-25">
<div class="day-contents">25</div>
</td>
<td class="day today calendar-day-2015-09-26">
<div class="day-contents">26</div>
</td>
</tr>
<tr>
<td class="day calendar-day-2015-09-27">
<div class="day-contents">27</div>
</td>
<td class="day calendar-day-2015-09-28">
<div class="day-contents">28</div>
</td>
<td class="day calendar-day-2015-09-29">
<div class="day-contents">29</div>
</td>
<td class="day calendar-day-2015-09-30">
<div class="day-contents">30</div>
</td>
<td class="day adjacent-month next-month calendar-day-2015-10-01">
<div class="day-contents">1</div>
</td>
<td class="day adjacent-month next-month calendar-day-2015-10-02">
<div class="day-contents">2</div>
</td>
<td class="day adjacent-month next-month calendar-day-2015-10-03">
<div class="day-contents">3</div>
</td>
</tr>
</tbody>
</table>
但是没有出现对话框。
使用Javascript:
<td class="day past calendar-day-2015-09-01">
<div class="day-contents" href="#alert" id="alert">1</div>
</td>
您可以通过按表格单元格向我提供有关如何显示对话框的建议吗? 问候
答案 0 :(得分:1)
您的桌子上没有锚标记。在jquery选择器中,您应该使用
$('div#alert').click(function(){})
$(document).ready(function(e) {
//alert
$('div#alert').click(function(){
alert('clicked');
modal({
type : 'alert',
title : 'Alert',
text : "Simple Message!"
});
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="clndr-table" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr class="header-days">
<td class="header-day">S</td>
<td class="header-day">M</td>
<td class="header-day">T</td>
<td class="header-day">W</td>
<td class="header-day">T</td>
<td class="header-day">F</td>
<td class="header-day">S</td>
</tr>
</thead>
<tbody>
<tr>
<td class="day past adjacent-month last-month calendar-day-2015-08-30">
<div class="day-contents">30</div>
</td>
<td class="day past adjacent-month last-month calendar-day-2015-08-31">
<div class="day-contents">31</div>
</td>
<td class="day past calendar-day-2015-09-01">
<div class="day-contents" href="#alert" id="alert">1</div>
</td>
<td class="day past calendar-day-2015-09-02">
<div class="day-contents">2</div>
</td>
<td class="day past calendar-day-2015-09-03">
<div class="day-contents">3</div>
</td>
<td class="day past calendar-day-2015-09-04">
<div class="day-contents">4</div>
</td>
<td class="day past calendar-day-2015-09-05">
<div class="day-contents">5</div>
</td>
</tr>
<tr>
<td class="day past calendar-day-2015-09-06">
<div class="day-contents">6</div>
</td>
<td class="day past calendar-day-2015-09-07">
<div class="day-contents">7</div>
</td>
<td class="day past calendar-day-2015-09-08">
<div class="day-contents">8</div>
</td>
<td class="day past calendar-day-2015-09-09">
<div class="day-contents">9</div>
</td>
<td class="day past event calendar-day-2015-09-10">
<div class="day-contents">10</div>
</td>
<td class="day past event calendar-day-2015-09-11">
<div class="day-contents">11</div>
</td>
<td class="day past event calendar-day-2015-09-12">
<div class="day-contents">12</div>
</td>
</tr>
<tr>
<td class="day past event calendar-day-2015-09-13">
<div class="day-contents">13</div>
</td>
<td class="day past event calendar-day-2015-09-14">
<div class="day-contents">14</div>
</td>
<td class="day past calendar-day-2015-09-15">
<div class="day-contents">15</div>
</td>
<td class="day past calendar-day-2015-09-16">
<div class="day-contents">16</div>
</td>
<td class="day past calendar-day-2015-09-17">
<div class="day-contents">17</div>
</td>
<td class="day past calendar-day-2015-09-18">
<div class="day-contents">18</div>
</td>
<td class="day past calendar-day-2015-09-19">
<div class="day-contents">19</div>
</td>
</tr>
<tr>
<td class="day past calendar-day-2015-09-20">
<div class="day-contents">20</div>
</td>
<td class="day past event calendar-day-2015-09-21">
<div class="day-contents">21</div>
</td>
<td class="day past event calendar-day-2015-09-22">
<div class="day-contents">22</div>
</td>
<td class="day past event calendar-day-2015-09-23">
<div class="day-contents">23</div>
</td>
<td class="day past calendar-day-2015-09-24">
<div class="day-contents">24</div>
</td>
<td class="day past calendar-day-2015-09-25">
<div class="day-contents">25</div>
</td>
<td class="day today calendar-day-2015-09-26">
<div class="day-contents">26</div>
</td>
</tr>
<tr>
<td class="day calendar-day-2015-09-27">
<div class="day-contents">27</div>
</td>
<td class="day calendar-day-2015-09-28">
<div class="day-contents">28</div>
</td>
<td class="day calendar-day-2015-09-29">
<div class="day-contents">29</div>
</td>
<td class="day calendar-day-2015-09-30">
<div class="day-contents">30</div>
</td>
<td class="day adjacent-month next-month calendar-day-2015-10-01">
<div class="day-contents">1</div>
</td>
<td class="day adjacent-month next-month calendar-day-2015-10-02">
<div class="day-contents">2</div>
</td>
<td class="day adjacent-month next-month calendar-day-2015-10-03">
<div class="day-contents">3</div>
</td>
</tr>
</tbody>
</table>
&#13;