gpt4 book ai didi

javascript - 如何将时间戳的按钮文本转换为 jquery 中的整数?

转载 作者:行者123 更新时间:2023-11-30 20:18:20 26 4
gpt4 key购买 nike

$(".BtnRed, .BtnTime1, .BtnTime2").click(function() { 
if ($(this).text() == "Green") {
$(this).text(new Date());
} else {
$(this).text("Green");
};
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="table table-hover table-condensed" border = "1px">
<thead>
<tr>
<td>HospitalNumber</td>
<td>PatientName</td>
<td>Procedure</td>
<td>Notes</td>
<td>Ward/Unit</td>
<td>Made Ready</td>
<td>Pre-Recovery</td>
<td>GA</td>
<td>Time-In Room</td>
<td>Time-Out Room</td>
<td>Post Recovery</td>
<td>Back On Ward</td>
<td>Time Difference</td>
</tr>
</thead>
<tbody>
<tr>
<td><br/></td>
<td><br/></td>
<td><br/></td>
<td><br/></td>
<td><br/></td>
<td>
<select>
<option class="MRR" value="Red - Not seen/Ready DNA">Red - Not seen/Ready DNA</option>
<option class="MRA" value="Canula" >Cannula</option>
<option class="MRA" value="Consent" >Consent</option>
<option class="MRG" value="Green">Green</option>
</select>
</td>
<td>
<select>
<option class="PRA" value="Delay" >Delay</option>
<option class="PRA" value="Stemi" >Stemi</option>
<option class="PRA" value="Consultants">Consultants</option>
<option class="PRA" value="Overrun">Overrun</option>
<option class="PRG" value="Green">Green</option>
</select>
</td>
<td><button class = "BtnRed btn-danger btn-block btn-outline-dark">Green</button></td>
<td><button class = "BtnTime1 btn-danger btn-block btn-outline-dark">Green</button></td>
<td><button class = "BtnTime2 btn-danger btn-block btn-outline-dark">Green</button></td>
<td>
<select>
<option class="PRRR" value="Red - Recovery Post GA">Red - Recovery Post GA</option>
<option class="PRRA" value="Monitor (Lab)">Monitor (Lab)</option>
<option class="PRRA" value="A/W Bed" >A/W Bed</option>
<option class="PRRA" value="Medical Review">Medical Review</option>
<option class="PRRG" value="Green">Green</option>
</select>
</td>
<td><button class = "BtnRed btn-danger btn-block btn-outline-dark">Green</button></td>
<td class = "TimeDiff"><br/></td>
</tr>
</tbody>
</table>

您好,我有一些调用类“.BtnRed、.BtnTime1、.BtnTime2”的 jQuery 代码,当单击按钮时它会以字符串格式显示时间戳。我想将格式转换为数值(例如整数),这样我就可以减去两个日期并计算出时差。

非常感谢!

最佳答案

同样使用获取时间的方法:

var d = new Date();
console.log(d.getTime());

可以找到更多详细信息here

关于javascript - 如何将时间戳的按钮文本转换为 jquery 中的整数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51704680/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com