我有一个由ajax调用生成的div列表
这是代码
function todolisttoday() {
$("#list").empty();
$("#counter").empty();
$.ajax({
url: '@Url.Action("GetTodayList", "Home")',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(),
type: 'POST',
dataType: 'json',
processData: false,
success: function (data) {
var list = data;
var count = Object.keys(data).length;
$("#counter").append('<b>' + "You have" + " " + count + " " + "appointments today" + '</b>');
for (var i = 0; i <= list.length - 1; i++) {
var timeobject = new Date();
timeobject.setTime(Date.parse(list[i].time));
var hours = timeobject.getHours();
var minutes = timeobject.getMinutes();
var ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
var divslist = '<div class="listdiv">' +
'<b >' + (i + 1) + '</b>' + "." + " "
+ '<b class="title">' + list[i].title + '</b>' + " "
+ '<b >' + strTime + '</b>' + '<b class="status">' + list[i].status +'<b>'
+ '</div>';
$("#list").append(divslist);
};
}
});
};
它们由此代码生成
var divslist = '<div class="listdiv">' +
'<b >' + (i + 1) + '</b>' + "." + " "
+ '<b class="title">' + list[i].title + '</b>' + " "
+ '<b >' + strTime + '</b>' + '<b class="status">' + list[i].status +'<b>'
+ '</div>';
我需要获得'<b class="status">' + list[i].status +'<b>'
当我点击div
我制作div点击事件
这是代码
$(document).on('click', '.listdiv', function() {
var appointmentTitle = $(this).text();
});
但它从div获取所有数据。
我如何才能获得class="status"
值?
答案 0 :(得分:2)
试试这个:
$(document).on('click', '.listdiv.status', function() {
var appointmentTitle = $(this).text();
});
这只会获得包含listdiv
和status
类的div。
答案 1 :(得分:1)
UPDATE T
SET POQty = D.POQty
FROM
[Tab-2 sourcing] T
INNER JOIN DemandPortal D
ON T.PONumber = D.PONumber
WHERE
D.POQty > T.OpenQuantity OR
(D.POQty < T.OpenQuantity AND D.POQty > T.AlreadyAlloted)
试试这个。