Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1100159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:50:22+00:00 2026-05-17T00:50:22+00:00

I have the following code: $(document).ready(function(){ $(.datepicker).each(function() { $(this).datepicker({ beforeShowDay: function(date){ return [$(this).parent().find(span.days).html(), ]

  • 0

I have the following code:

$(document).ready(function(){

   $(".datepicker").each(function() {

     $(this).datepicker({
    beforeShowDay: function(date){ return [$(this).parent().find("span.days").html(), ""] },

     });
   });

  });

With this body code…

<div>
<span class="days">(date.getDay() == 1 || date.getDay() == 4)</span>
<input type="text" class="datepicker">
</div>


<div>
<span class="days">(date.getDay() == 2 || date.getDay() == 5)</span>
<input type="text" class="datepicker">
</div>

What I want to be able to do is have each datepicker have different days pickable.

The way i’m trying to do this (putting the varying part of the beforeShowDay code in a span) may not be the most elegant so feel free to take my code apart and change it if necessary.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:50:23+00:00Added an answer on May 17, 2026 at 12:50 am

    You could create an object keeping the pickable days, like this:

    var pickable = { dp1: [1, 4], dp2: [2, 5] };
    $('.datepicker').each(function() {
      $(this).datepicker({
        beforeShowDay: function(date){ 
            var day = date.getDay(), days = pickable[this.id];
            return [$.inArray(day, days) > -1, ""];
        }
      });
    });​
    

    You can give it a try here. The dp1 and dp2 are IDs of the controls..or any attribute you can map really, like this:

    <input type="text" class="datepicker" id="dp1">
    <input type="text" class="datepicker" id="dp2">
    

    The concept is pretty simple, take the ID to get the array of days for this picker, then use $.inArray() to see if the day we’re on is in that array. If these day selections may be shared, don’t use an ID, instead do something like data-pickerType for the attribute, and replace this.id with $(this).attr("data-pickerType") in the code above.

    Note: I left the .each() intact because I know you need it for reasons outside the current question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following code: $(document).ready(function() { $('a[rel]').each(function() { $(this).qtip( { content: { text:
I have the following code $(document).ready(function() { $('a#slick-toggle').click(function() { $('#slickbox0').toggle(400); return false; }); });
I have the following code: $(document).ready(function(){ $(.yearInner).hide(); $(.year, this).hover( function () { $(.yearInner, this).slideToggle();
Under $(document).ready(function() , I have the following code: num = $(#mainContentCategoryLinksWrapper > div).size(); This
I have the following code: <script> $(document).ready(function() { $('.toggle_section').click(function(e){ parent = $(e.target).closest(div) objChild =
have the following code: $(document).ready(function() { $.get(https://www.somesite.com/Securepay/Return.aspx, function(data) { alert(data); $(#result).html(data); }); }); the
I have the following code: $(document).ready(function() { $('.container').ready(function() { var v = new Video($(this));
I have the following code $(document).ready(function() { $(#myTextArea).focus(function() { $(#myTextArea).animate({ height: 75px}, normal); return
I have the following code: $(document).ready(function() { $(#TestLink).click(function() { $(#LinkHolder).html(test); }); }); <span id=LinkHolder>
I have the following jquery code: $(document).ready(function() { $(#build_table, a.coursename, .Start Date, .Book Title,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.