Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with getElementById 2

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR

Below is a clumsy (but working) attempt of getting the offsetTop of an element that is repeated many times within the document.

The question is : was there another simpler method, without the need of a loop for instance?

Code:
document.onmousemove = function(ev){

    if (currenttable && currenttable.dragObject) {
    
    var elems = currenttable.dragObject.getElementsByTagName('div');

        for (var i=0; i<elems.length; i++) {

         		if (elems[i].getAttribute( 'id' ) == 'bottom-area') {

         		currenttable_height = elems[i].offsetTop;
         		
         		}         		

        }

I've tried
var elem = currenttable.dragObject.getElementById('bottom-area');
but it throws an error ("... is not a function")

Thanks! :)
 
Hello,

Nope, it's not an unique ID.
How do I do in that case?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top