我是网络开发新手并开始走上路径,最近我为我哥哥的网吧建立了一个时间管理器,并选择了jquery和javascript来处理。我难以为追加提供唯一的ID值,我需要为每个标签设置唯一ID的原因是我需要编辑这些值。任何人或某人可以帮忙吗?
<head>
<script src="scripts/jquery-3.2.1.min.js"></script>
<script src="scripts/sys.js"></script>
<script src="scripts/moment.js"></script>
<script src="scripts/jquery.playSound.js"></script>
<style>
td{
align:center;
}
</style>
</head>
<body>
<div>
<table border="1" width="80%" height="10%" align="center">
<tr>
<td width="20%" align="center">Client/PC</td>
<td width="20%" align="center">Start Time</td>
<td width="20%" align="center">End Time</td>
<td width="20%" align="center">₱ Amount</td>
<td width="20%" align="center">Status</td>
</tr>
</table>
</div>
<div id="here_table"></div>
<button id="addnew" style="position:relative; margin-top:10px; left:43%;">Add Cafeteria</button>
</body>
这是我的java脚本
$(document).ready(function (){
$('#addnew').click(function(){
var client = prompt('PC/Client number?');
if (client > 6){
alert('PC/Client not found');
return false;
}
else if (isNaN(client)){
alert('Invalid Entry,must be a number');
return false;
}
else if(client === null){
return false;
}
else if (client == 0){
alert('No entry!')
return false;
}
var tothour = prompt('Hours?');
var amount = tothour * 10;
if (tothour == 3 ){
tothour = 3 + 1;
}
var status = "<select style='padding:2px; margin:4px;'><option></option><option>Paid</option><option>Unpaid</option></select>";
var starttime = new Date();
starttime = starttime.toLocaleString('en-US', { hour: 'numeric', minute:'numeric', hour12: true });
endtime = moment().add('hours', tothour).format('h:mm A')
var tab = '<table border="1" width="80%" height="10%" align="center">'
for(i=0; i<1; i++){
tab += '<tr><td width="20%" align="center">' + client + '</td><td width="20%" align="center">'+ starttime +'</td><td width="20%" align="center">'+ endtime +'</td><td width="20%" align="center">'+ amount + '</td><td align="center">' + status + '</td></tr>';
}
tab +="</table>"
$('#here_table').append(tab);
setTimeout(function(){$.playSound('notif.mp3');},3600000*tothour);
});
});