我在表格中制定了时间表。每个td都有一个以“schedule”+dayofweek开头的id; 我标记时间表何时开始添加类“.schedule_start”。 我正在使用选择器进行搜索,我想获取“schedule_start”类的 td 的完整 ID
这是我的例子:
for (i = 0; i < 7; i++) {
var tag1 = 'schedule-' + i + '-';
if($("td[id ^='" + tag1 + "']").hasClass("schedule_start"))
{
console.log(tag1);
// here i want to return the full id
}
}
最佳答案
您可以这样做:
$('td[id^=schedule].schedule_start').each(function() {
console.log(this.id);
});
关于javascript - 使用选择器进行完整 ID 搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26219813/