Avatar of Babak Sekandari
Babak Sekandari
Flag 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

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Michel Plungjan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Babak Sekandari

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");
lenamtl

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

Michel Plungjan

Yes.

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

would change a text input field with class=myDateDiv into a datepicker
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy