Jump to content
Larry Ullman's Book Forums

Recommended Posts

Am I approaching this correctly? I'm trying to produce a datepicker widget but it's not working. Here is the code:



<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<meta http-equiv="content-type" content="text/html; charset=utf-8"/>




<h1>This is a JQuery test of it's plug-ins</h1>

<a href='' id= 'dateInput'><p id= 'pickOne'>Please select a date</p></a>


<script src= 'utilities/jquery-1.8.3.js'></script>

<script src= 'utilities/jquery-ui-1.9.2.custom.min.js'></script>

<script src= 'utilities/jquery.ui.datepicker.js'></script>

<script type= 'text/javascript'>$('#dateInput').onclick(function(){$('#pickOne').datepicker();})</script>



Link to post
Share on other sites

I like to be safe than sorry, there has been plenty of times when I forgot that little function and couldn't get the script to work.. :( Even when I tested it it wouldn't work without the ready function.


@Christoper, don't forget you can shorten the ready function to this if you like.


$(function() {




Basically the point of the post was to have an input element not a paragraph element.

Link to post
Share on other sites

I rarely use jQuery, so I'm not sure why your scripts sometimes don't work without the ready method, but no script should ever be dependent on the ready method.

The only thing the ready method really gives you is the ability to set up event handlers slightly sooner than you'd be able to with the standard onload event handler. If anything, using the ready method could cause issues that otherwise wouldn't be present.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...