[英]How can i get the date of month from a date in Jquery/javascript from input type
當循環輸入日期類型時,我無法提取當前日期,這意味着當我在日期上應用 getDate() 時,我會得到一個隨機數。
jQuery(".JESUSISKINGANDIWILLBEINTHESCHOOLOFDAVIDHOGAN input[type=date]").each(function(){
var date = new Date(jQuery(this).val());
}
很難說你想要完成什么,但是我盡力幫助你尋找解決方案。
在下面提供的示例中,如果 smth 發生更改,我將循環遍歷所有數據字段。
這是 JSfiddle: https ://jsfiddle.net/mkbctrlll/8zfxhpuL/31/
<form id="date-test" action="">
<input type="date" id="1">
<input type="date" id="2">
<input type="date" id="3">
<input type="date" id="4">
<input type="date" id="5">
<input type="date" id="6">
<input type="date" id="7">
<input type="date" id="8">
<input type="date" id="9">
<input type="date" id="10">
</form>
const $dateFields = $('[type="date"]')
console.log($dateFields)
$('#date-test').on('change', function(event) {
console.log(`Chosen value: ${ $(event.target).val() }`)
loopDateFields()
})
function loopDateFields() {
$dateFields.each(function(index, singleField) {
console.log(`The field no#${ index } has the following value: ${ $(singleField).val() }`)
})
}
如果您需要更具體的幫助,請更詳細地說明您的問題。 現在真的很難理解你在這里想要實現的目標。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.