troubleshooting Question

How do I add HTML to this datepicker tool tip?

Avatar of dzash2000
dzash2000Flag for United States of America asked on
JavaScriptWeb Frameworks
3 Comments1 Solution1372 ViewsLast Modified:
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:
    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

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

I hope this is enough information for an expert to help me with this questions.
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros