I was reading the jQuery UI API for datepicker. The example code has something new to me.
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$("#datepicker").datepicker();
});
</script>
</head>
<body style="font-size:62.5%;">
<div type="text" id="datepicker"></div> <<<<<<<<<<<<<<<<<<<<<<<<<"type"???
</body>
</html>
I tried it without type=”text” and it doesn’t work anymore. Why is that?
I’m new to HTML and I have never seen assigning a type to div. Searching on the Internet, I couldn’t find any example for div. All I see is type for other elements like style and script. I couldn’t find any relevant questions at stackoverflow either.
Why would we need to assign a type to div?
Ref: download jquery-ui-1.8.14.custom.zip. It’s in the “development-bundle\docs\datepicker.html#demo” (the official demo code in the offline documentation for jquery-ui datepicker)
Edit: it turned out to be a bug in the documentation of jquery datepicker demo code. I reported it and they fixed it within few hours so this question doesn’t apply to the latest version of the document.
Actually, i couldn’t find any reference to the fact that you had to use a div in the documentation, what i’m sure of is that you must use an input of type text. Taken from the demo:
Moreover: what do you need a datepicker for if you have no input field?