jQuery function and document ready the same

0 votes

To have a working datepicker on a field, I have to put this script inside my element

$( function() {
  $( "#date_datepicker" ).datepicker( { dateFormat: "yy-mm-dd" } );
});

Removing the $( function() { makes the datepicker not work.

So does it mean that the $( function() { is the same as $(document).ready?

I'm trying to optimize my javascript codes so knowing this might help.

Jun 13, 2022 in JQuery by gaurav
• 23,260 points
714 views

1 answer to this question.

0 votes

So technically they are both the same. Not major difference between these two declaration. They used based on weather you use JavaScript then you should use $(document). ready declaration in other case you use jQuery library which is a part of JavaScript then you should use $(function) declaration

answered Jun 13, 2022 by rajatha
• 7,680 points

Related Questions In JQuery

0 votes
1 answer

How can I implement my own $(document).ready functionality without using jQuery?

Hello @kartik,  There are three options: If script is the last ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
1,783 views
0 votes
1 answer

How to use $(document).ready equivalent without jQuery

Hello @kartik, Using DOMContentLoaded that is supported by over ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,840 points
1,628 views
0 votes
1 answer

Difference between $(window).load() and $(document).ready() functions

To answer your question, the document.ready is ...READ MORE

answered Feb 23, 2022 in JQuery by Aditya
• 7,680 points
1,696 views
0 votes
1 answer
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,520 points
1,350 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
15,882 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
23,392 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,840 points
3,341 views
0 votes
1 answer

Difference between $(window).load() and $(document).ready() functions

The key difference between $(document). ready() and ...READ MORE

answered Jun 17, 2022 in JQuery by rajatha
• 7,680 points
18,011 views
0 votes
1 answer

difference between $ and $() in jQuery

JavaScript: It is a major scripting programming language ...READ MORE

answered Jun 10, 2022 in JQuery by rajatha
• 7,680 points
560 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP