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 7976547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:56:12+00:00 2026-06-04T08:56:12+00:00

When I click the anchor, I find that date is not defined. How should

  • 0

When I click the anchor, I find that date is not defined. How should I make sure the parameters are in the scope of the self-calling function that I pass to onclick?

var date = today; // today is well-defined at this point.

html += '<a onclick="(function(obj, myDate) { \
        return function() { \
           obj.render(myDate.setMonth(myDate.getMonth() - 1));  \
        };  \
      })(this, date);">&lt;</a>'

Edit: Is this HTML valid?

today is well-defined. This snippet of code lives inside this function:

Calendar.prototype.render = function(date) {

}
  • 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-06-04T08:56:14+00:00Added an answer on June 4, 2026 at 8:56 am

    When an event is raised, the only context it has is the window context.

    you have to set up a global var in order for it to be available within the event callback code when using on<event> attributes.

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

Sidebar

Related Questions

Easy enough to make a div with a background image clickable: $(.socialMedia).click(function(){ window.location=$(this).find(a).attr(href); return
I bound a function as a closure to an anchor like this: jQuery('#mydiv').find('#mya').bind('click', function(e){
my UI is <li><a href='#'>hello</a></li> anchor tag has already event handler i.e. click(function(){}) I
I have an element, an anchor, how can I click it with jQuery, I
I click on a link from one page that does a redirect to another
I am using .toggle to expand/retract individual divs with the click of an anchor
I have a container and inside that I have several anchor tags. These anchor
I am using jQuery to create an anchor and bind it with JavaScript function
I have a problem with faking an anchor click via jQuery: Why does my
I've created a list item element that contains a child anchor element. <ul id=machine-list>

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.