【发布时间】:2017-11-10 08:45:42
【问题描述】:
大家好,我正在开发我的新 MVC 应用程序,但是... 我想使用此代码的功能不起作用。 当用户点击一个任务时,它必须出现在段落中。 如您所见,该函数仅适用于第一个表格项。
$(document).ready(function(){
$("#btnAdd").click(function () {
var task = $('#taskDescription').val();
$("#paragraph").append(task, " <button>-</button></br>");
});
});
.table-left {
width: 30%;
display: inline-block;
}
tbody {
overflow: scroll;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="table-left">
<table class="table table-bordered">
<thead>
<tr>
<th>Dienst</th>
</tr>
</thead>
<tbody>
<tr>
<td>hey</td>
<td><button id="btnAdd">+</button></td>
<input type="hidden" id="taskDescription" value="hey" />
</tr>
<tr>
<td>hi</td>
<td><button id="btnAdd">+</button></td>
<input type="hidden" id="taskDescription" value="hi" />
</tr>
<tr>
<td>hello</td>
<td><button id="btnAdd">+</button></td>
<input type="hidden" id="taskDescription" value="hello" />
</tr>
<tr>
<td>bye</td>
<td><button id="btnAdd">+</button></td>
<input type="hidden" id="taskDescription" value="bye" />
</tr>
</tbody>
</table>
</div>
<p id="paragraph"></p>
谁知道该怎么做? 我读了这篇文章:Why the jQuery Selectable plugin doesn't work with a foreach generated list?
但这似乎并没有解决我的问题
【问题讨论】:
标签: jquery html asp.net-mvc