473,320 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

possible to add methods to HTMLElements?

Hi, I'm trying to add the method nextSibling to a HTMLElement such as
a DIV in the body of a html document.
Once the function nextSibling was defined
function sibling () {
return( document.all[this.children.length+1] );
}
I tried to add the method by the following instruction
HTMLElement.prototype.nextSibling=sibling;
but it seems it does not work. Probably the class has to be named
somehow else. Who knows a complete list of classes/object?

Can anyone help? TIA
Jul 20 '05 #1
1 1380


lopi wrote:
Hi, I'm trying to add the method nextSibling to a HTMLElement such as
a DIV in the body of a html document.
Once the function nextSibling was defined
function sibling () {
return( document.all[this.children.length+1] );
}
I tried to add the method by the following instruction
HTMLElement.prototype.nextSibling=sibling;
but it seems it does not work. Probably the class has to be named
somehow else. Who knows a complete list of classes/object?


It obviously depends on the browser but for a start try the DOM section
on http://www.w3.org/, there you will find that nextSibling is a
property defined in DOM Level 2 Core.
As for adding method to HTMLElement, as far as I know only Mozilla based
browsers allow that, others like IE or Opera don't do that.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: James CC | last post by:
Hi there, I have a function, converted from VB, that is passed an object, and sets it up. The object passed is either a ListBox or a ComboBox. The code checks to make sure that the object passed...
5
by: Cyril Gupta | last post by:
Hello, I have a class inside another class. The Scenario is like Car->Engine, where Car is a class with a set of properties and methods and Engine is another class inside it with its own set of...
11
by: Ranginald | last post by:
This question is about how to handle an .aspx page that references multiple methods and where to store these methods (e.g. one codefile or multiple codefiles). PREFACE ======== I have a simple...
6
by: PJ6 | last post by:
I would like to refer to properties in code without having to resort to using a string for the name. AddessOf gives me this ability for methods, but I can't find a single way to point that at the...
11
by: Martin Höfling | last post by:
Hi there, is it possible to put the methods of a class in different files? I just want to order them and try to keep the files small. Regards Martin
1
by: Joe Peterson | last post by:
I've been doing a lot of searching on the topic of one of Python's more disturbing issues (at least to me): the fact that if a __del__ finalizer is defined and a cyclic (circular) reference is...
2
by: Daz | last post by:
Hi everyone. Sorry for the confusing subject, I couldn't think how best to word it. What I would like to know, is if there is an equivilant to this code, in using JSON. <script...
7
by: Zytan | last post by:
I know you cannot have a sealed static class, but why not? Why must static classes be left open to inheritance? This article: http://msdn.microsoft.com/msdnmag/issues/03/07/NET/ recommends to...
1
by: gregory.lielens | last post by:
Hello, We are currently writing python bindings to an existing C++ library, and we encountered a problem that some of you may have solved (or that has found unsolvable :( ): A C++ class...
3
by: | last post by:
I am enjoying making generalized methods to serve common needs, such as: ImageProcessing.MakeQuickResize(); ImageProcessing.Sharpen(); FileOps.CreateYearAndMonthAndDayDirectoryBasedOnDate()...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.