By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

trying to get an attribute value

P: n/a
Hello,
I'm trying the following code:
function MoveTeam(id){
This works-gets the value of the element
var x=document.getElementById(id).innerHTML;
This doesnt get the value of the alpha attribute of the same element.
I get a js error.
var q=document.getElementByID(id).attribute('alpha')
alert (q)

Thanks
Mike
Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Mike wrote:
Hello,
I'm trying the following code:
function MoveTeam(id){
This works-gets the value of the element
var x=document.getElementById(id).innerHTML;
This doesnt get the value of the alpha attribute of the same element.
I get a js error.
var q=document.getElementByID(id).attribute('alpha')
alert (q)
Thanks
Mike
You've upper-cased the ID in getElementById.
Jun 27 '08 #2

P: n/a
SAM
Mike a écrit :
Hello,
I'm trying the following code:
function MoveTeam(id){
This works-gets the value of the element
var x=document.getElementById(id).innerHTML;
This doesnt get the value of the alpha attribute of the same element.
what is an alpha attribute ?
I know style (style="filter:alpha(50)")

but ... alpha as attribute of a div ... no I doesn't know.

I get a js error.
var q=document.getElementByID(id).attribute('alpha')
if(document.getElementsByTagName("body")[0] &&
document.getElementsByTagName("body")[0].hasAttribute &&
document.getElementsByTagName("body")[0].hasAttribute('style') )
alert(document.getElementsByTagName("body")[0].getAttribute('style'));

<http://developer.mozilla.org/en/docs/DOM:element.getAttribute>

--
sm
Jun 27 '08 #3

P: n/a
In comp.lang.javascript message <48*********************@news.orange.fr>
, Tue, 13 May 2008 18:17:01, SAM <st*********************@wanadoo.fr.inv
alidposted:
>
if(document.getElementsByTagName("body")[0] &&
document.getElementsByTagName("body")[0].hasAttribute &&
document.getElementsByTagName("body")[0].hasAttribute('style') )
alert(document.getElementsByTagName("body")[0].getAttribute('style'));
I think the following might work more efficiently :-

if ( (T=document.getElementsByTagName("body")[0]) &&
(T=TT.hasAttribute) && (T=T('style')) ) alert(T);
// ^ ?

Certainly there should be no need to repeat
document.getElementsByTagName("body")[0].hasAttribute('style')
except for those paid for code by the yard.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.