We help IT Professionals succeed at work.

How do I add HTML to this datepicker tool tip?

dzash2000 asked
Last Modified: 2012-05-11
Hi - I am not a javascript programmer but I can cut and paste with the best of 'em. ;)
I found the code below to generate tooltips over specified dates on a jquery datepicker.  It works superbly for short text strings but I'd like to add more html functionality such as: line break tags, and links.

<script language="JavaScript" type="text/javascript">$(function() {
    // format: specialDays.year.month.day
    var specialDays = {
      '2011': {
        '1': {'1': {tooltip: "New Year's Day", className: "holiday"}},
        '4': {
          '10': {tooltip: "Good Friday", className: "holiday"},
          '13': {tooltip: "Easter Monday", className: "holiday"}
        '5': {
          '4': {tooltip: "Early May Bank Holiday, 9-6,"+<br />+"1120 Mill Road, Egg Harbor Twp", className: "holiday"},
          '15': {tooltip: "Spring Bank Holiday", className: "holiday"}
        '8': {'31': {tooltip: "Summer Bank Holiday", className: "holiday"}},
        '12': {
          '25': {tooltip: "Christmas Day", className: "holiday"},
          '28': {tooltip: "Boxing Day", className: "holiday"}
    $('#datepicker').datepicker({beforeShowDay: function(date) {
      var d = date.getDate(),
        m = date.getMonth()+1,
        y = date.getFullYear();
      if (specialDays[y] && specialDays[y][m] && specialDays[y][m][d]) {
        var s = specialDays[y][m][d];
        return [true, s.className, s.tooltip]; // selectable
      return [false,'']; // non-selectable

Open in new window

Then this is in the body:
<div id="datepicker"></div>

Open in new window

I hope this is enough information for an expert to help me with this questions.
Watch Question

Expert of the Year 2008
Top Expert 2008
This one is on us!
(Get your first solution completely free - no credit card required)


Thanks for that response. The link displayed as text.  I also realized that putting a link in this tooltip itself is useless since as soon as I roll off the date the tooltip disappears.  The link would have to be date square itself.


The response did not help me do what I needed but it did get me to realize that I was asking the wrong question.
Valuable in its way.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.