473,513 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about JavaScript closure (while attaching an event handler)

dmjpro
2,476 Top Contributor
I am adding a table inside a TD
Expand|Select|Wrap|Line Numbers
  1. function addTable(){
  2. td_ref = ....
  3. table_ref =......
  4. table_tr_ref = ....
  5. table_ref.appendChild(table_tr_ref );
  6. a_button_ref = ....
  7. ...
  8. ....
  9. a_button_ref.onclick = function(){another_handler(this);}
  10. table_tr_ref.appendChild(a_button_ref);
  11. ...
  12. td_ref.appendChild(table_ref);
  13. }
  14.  
Now tell me experts what bold this refers to ?
Please clarify..actually what happens ..it refes to teh current object..means the Button.
Feb 11 '09 #1
3 1237
acoder
16,027 Recognized Expert Moderator MVP
See this example + explanation.
Feb 11 '09 #2
dmjpro
2,476 Top Contributor
Thanks for your help.
But Acoder tell me one thing so suitable link ..how can you get and how can you remember ... did you bookmark those links ? :P
Feb 11 '09 #3
acoder
16,027 Recognized Expert Moderator MVP
It's just a case of searching well, and with quite a lot of similar questions, it's the same links (some bookmarked, some stay in the head).

Oh, and you're welcome.
Feb 11 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
9926
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the links in my fireworks-generated dhtml popup menus. Does anyone here know where I would add this javascript fucntion in the code so that it would be...
5
6062
by: Justice | last post by:
Currently I'm doing some experimenting with the XMLHTTP object in Javascript. Now, the XMLHttp object is asynchronous (at least in this case), and the following code causes a significant memory loss even though I seem to be allocaitng everything; help would be *vastly* appreciated. What am I doing wrong here? I thought I was doing...
2
5248
by: yawnmoth | last post by:
Say I had <select id="something" name="something" onchange="demo(this.value)"> but didn't want to define the onchange event handler in the select tag, itself. ie. I wanted to attach it, latter, by doing something like... document.getElementById('something').attachEvent('onchange',demo); or this: ...
10
2055
by: Emre Sevinc | last post by:
Take a look at the following snippet: <html> <head> <script> function add(elementId) { var container = document.getElementById(elementId); for (var i = 0; i < 10; i++) { var elt = document.createElement('div'); elt.innerHTML = "" + i;
10
1946
by: lkagan2000 | last post by:
I'm reading 'Ajax in Action', (one of the best of the many tech books I've read) and there's an example that I just don't fully understand. If you happen to have the book, it's on page 75. I'm hoping someone can enlighten me. var loader = this; this.req.onreadystatechange = function() { loader.onReadyState.call(loader); }
4
2125
by: eggie5 | last post by:
I have this even handler (using prototype.js): showCommentsLinks.observe('click', function(event) { alert('hi') }); It's attaching to a link element: <a id="showCommentsLink" href="comments/">Show Comments</a>
2
1263
by: Kidogg | last post by:
Hi all, First let me apologize for being an idiot when it comes to Javascript, I've only recently had to do any serious work in it - and I'm properly stuck already! Essentially I'm trying to bind a click event (using MooTools) to a <div>, but inside the event handler have access to an object (of my own creation) that "owns" the <div>. So...
2
1228
by: Oltmans | last post by:
Hi all, I'm stuck in a situation where I need help. Any help will be highly appreciated. I've created an object, after creating the object, I'm assigning one of its functions to an event handler i.e. to onBlur event of Text-area. Problem is that when I try to access object properties from the handler function, I cannot access them in some...
19
2186
by: maya | last post by:
hi, so what is "modern" javascript?? the same as "DOM-scripting"? i.e., editing content (or changing appearance of content) dynamically by massaging javascript objects, html elements, etc? (in conjunction with css, you know, the usual...;) this is what is meant by "modern" javascript?? so how do folks feel about this who think...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7563
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7125
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.