Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
137
rated 0 times [  141] [ 4]  / answers: 1 / hits: 20787  / 15 Years ago, tue, december 8, 2009, 12:00:00

I've got this code:



<html>
<head>
<link type=text/css href=css/blitzer/jquery-ui-1.7.2.custom.css rel=stylesheet />
<script type=text/javascript src=js/jquery-1.3.2.min.js></script>
<script type=text/javascript src=js/jquery-ui-1.7.2.custom.min.js></script>
<script type=text/javascript>
$(function() {
$('.hasDatepicker').datepicker();
});
</script>
</head>
<body>
<p>date: <input type=text name=data class=hasDatepicker /></p>
<input type=submit value=send />
</div>
</body>
</html>


When I click the input field, nothing happens. The datepicker is initialized though, when I inspect the DOM in Firebug, I get the id=dp1260260566059 added to my <input> element.



After changing the html and js to use id attribute instead of class, so having this in my code:



$(function() {
$('#hasDatepicker').datepicker();
});


and



<p>date: <input type=text name=data id=hasDatepicker /></p>


Everything works OK.



Can't datepicker from JQuery UI work for all elements of some class?


More From » jquery

 Answers
3

Please check if the datepicker works if you change the class name of the input fields from 'hasDatePicker' to something else. The reason is, when add the datepicker to the input field using the below code:



$(function() {
$('#date').datepicker();
});


it adds the class name hasDatePicker to the input field. (which is the one u r using)


[#98123] Friday, December 4, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yaquelina

Total Points: 517
Total Questions: 101
Total Answers: 96

Location: Egypt
Member since Tue, Jul 6, 2021
3 Years ago
yaquelina questions
;