<!doctype html> <html lang="en"><head> <meta charset="utf-8" />
<title>jQuery UI Datepicker - Icon trigger</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() { $( "#datepicker" ).datepicker({ showOn: "button", buttonImage: "img/calendar.gif", buttonImageOnly: true }); }); </script>
</head>
<body>
<p>Date: <input type="text" id="datepicker" /></p>
<p>Date: <input type="text" id="datepicker" /></p>
</body>
</html>
哪位jquery大神帮我看看代码吧~不明白。想做酒店的入住日期和退房日期……输入了两个Date只显示一个,另一个显示不出来日历~应该怎么改??
把$( "#datepicker" )改成$( "['id'='datepicker']" )
或者给两个文本框不同的id,然后把$( "#datepicker" )这一段代码写两遍。
要命名成不一样的才行
datepicker1,datepicker2
$( "#datepicker1,#datepicker2" ).datepicker({ showOn: "button", buttonImage: "img/calendar.gif", buttonImageOnly: true });
$(function() { $( "#datepicker1" ).datepicker({ showOn:
"button", buttonImage: "img/calendar.gif", buttonImageOnly: true });
});
$(function() { $( "#datepicker2" ).datepicker({ showOn:
"button", buttonImage: "img/calendar.gif", buttonImageOnly: true });
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker1" /></p>
<p>Date: <input type="text" id="datepicker2" /></p>