Avatar of Babak Sekandari
Babak SekandariFlag for United States of America

asked on 

Help Understanding JQuery DatePicker

I need help understanding the JQuery DatePicker widget examples here:

https://api.jqueryui.com/datepicker/#entry-examples


First of all, in JQuery, what's the difference between

$(...).

and

$.


I understand,

$(".xxx") selects elements with class xxx

$("#xxx") will select an element with id xxx

$(button) selects button elements 


But I don't understand, $.


The explanation here made no sense to me:

https://stackoverflow.com/questions/22156664/what-does-the-dot-after-dollar-sign-mean-in-jquery-when-declaring-variables


In the examples on the JQuery datepicker tutorial, what is this:

$.datepicker. 


What is this:

$( ".selector" ). 

Is it saying that some element with the class, "selector" has a datepicker object in it?

But then, when I try this, it only shows the input element:

<div><input class="test">
 
<script>
$( ".test" ).datepicker("show")
</script>

Open in new window

Even though this works:

$( ".test" ).hide();


That's from the show() example in:

https://api.jqueryui.com/datepicker/#entry-examples


How would code like:

$( ".selector" ).datepicker( "show" );
// and
$.datepicker.parseDate( "yy-mm-dd", "2007-01-26" )

Open in new window

work in a full example like in this context:

<body>
<div id="datepicker"></div>
<script>
$( "#datepicker" ).datepicker();
</script>
</body>

Open in new window


thanks in advance





jQuery

Avatar of undefined
Last Comment
Michel Plungjan
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Babak Sekandari
Babak Sekandari
Flag of United States of America image

ASKER

Very helpful.
Thanks you.

But in the datepicker documentation, what is $( ".selector" )
For example, is
$( ".selector" ).datepicker( "show" );
an abstract way of showing something like,
$( "myDateDiv" ).datepicker( "show" );

Because when I try it, this works:
$( "#myDateDiv" ).datepicker();

But this does nothing:
$( "#myDateDiv" ).datepicker("show");
Avatar of lenamtl
lenamtl
Flag of Canada image

Hi,

First, I would recommend to use a better date picker as the one you use is very limited.

You will save a lot of time using using one of these datepicker

I'm using
https://github.com/uxsolutions/bootstrap-datepicker
Demo https://uxsolutions.github.io/bootstrap-datepicker/

or if you need the date & time
https://github.com/Eonasdan/tempus-dominus

Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Yes.

$( ".myDateDiv" ).datepicker( "show" );

would change a text input field with class=myDateDiv into a datepicker
jQuery
jQuery

jQuery (Core) is a cross-browser JavaScript library that provides abstractions for common client-side tasks such as Document Object Model (DOM) traversal, DOM manipulation, event handling, animation and Ajax. jQuery also provides a platform to create plugins that extend jQuery's capabilities beyond those already provided by the library.

19K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo