Hey guys I'm working on my new MVC app but... The function I want to have with this code doesn't work. When the user clicks on a Task, it has to appear in the paragraph. As you can see the function only works with the first table item.
$(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>
Who knows what to do? I read this post: Why the jQuery Selectable plugin doesn't work with a foreach generated list?
But it doesn't seem to solve my problem