Here i am trying to find the taskid present in anchor tag using Jquery on click of that anchor tag having class=POtskComment.
But as i click the anchor tag taskid id is undefined.
Any help will be heartly thankful.Thank You
Below is my Html
@foreach (var item1 in Model)
{
<tbody>
<tr>
<td>
<a class="POtskComment" taskid="@item1.TaskId" tskassinid="@item1.TskAssId" tskname="@item1.TaskName">
@Html.DisplayFor(modelItem => item1.TaskName)
</a>
</td>
</tr>
</tbody>
}
Below Is Jquery
<script>
$(document).ready(function (event) {
$(".POtskComment").click(function (event) {
var paramTaskId3 = $(this).closest("tr").find("td").attr("tskid");
var parameter = { taskId: paramTaskId };
$.ajax({
url: "/TaskAssignedDailyLogs/_POIndex",
type: "get",
dataType: "html",
data: parameter,
success: function (data)
{
$("#reportResult").html(data);
}
});
});
});
</script>
Try this
var paramTaskId3 = $(this).attr("taskid");
the attribute is also misspelled
错别字:应该是'taskid'而不是'tskid',因为您的attr是在anchor标签上,而不是td标签上,因此请使用$(this).attr('taskid');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.