getElementById(ohBoy)

They have: 7 posts

Joined: Apr 2006

I need to know any and all equivalent code to the getElementById() function.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Hey kker, melcome to TWF! Smiling

I can't name a drop-in replacement to getElementbyId with the same parameters and return type -- that would be redundant.

Related methods are listed here: Section 1.2 Fundamental Interfaces in the DOM Core, mainly under Document Interface. getElementsByTagName is probably nearest to getElementById.

We could probably give you a more helpful answer if you give us details about your problem or what you're trying to achieve. Smiling

They have: 7 posts

Joined: Apr 2006

Well, my main concern with it is with DHTML, changing CSS values, mainly "filter:Alpha(opacity=XXX)"

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

What exactly are you concerned about with it? I don't see any problems with getElementById and CSS properties. Whatever selector you use, you should ultimately operate on the same object, the same way.

Is something not working? Can you show us code?

Smiling

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

document.getElementById() is possibly the most important function in the DOM, it's the basis for practically everything! Naming a replacement to this is functionally impossible, but am also certain you should be able to achieve the results you need with it.

Let us know if you're trying to do something like the following:

document.getElementById('elementname').style.background = 'black';
'

That'll set the elements background to black for instance. If you give us more details about what you're trying to do, and/or show us code we can help you more. Smiling

a Padded Cell our articles site!

They have: 7 posts

Joined: Apr 2006

Actually, it's more like:

var alph = 0;
function appear(){
alph += 10;
document.getElementById(object).style.filter = "Alpha(opacity="+alph+")";
setTimeout("appear()",10);
}
'
...
I think. 'cause it's on my other computer. My code works on IE, but I want to put it on the web for everyone, and I want people to see it.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

It works in IE because the 'filter' CSS property is a non-standard IE extension. MSDN: filter attribute, values.

Though there is no alpha/opacity property in CSS 2.1, CSS3 will have it.

Other browsers support opacity properties to varying degrees. Mozilla has a non-standard CSS extension called -moz-opacity. It takes a value between 0 and 1.0, though, as does Safari. Opera 9 will support opacity. I don't think Konqueror supports it at all.

This can be very fiddly to make work across platforms. It has nothing to do with your getElementById selector. Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.