473,396 Members | 1,792 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,396 software developers and data experts.

trying to get an attribute value

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
3 1922
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
0
by: David Elliott | last post by:
I am looking to use a field attribute in a to find and use a property. If given Find("Record Artist", "Billy Joel"); I am looking to find the first instance in the collection where the value the...
1
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
4
by: Lénaïc Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I've some namespace problems when defining default values for attributes. My problem seems to come from the fact that the attributes are...
1
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
5
by: Soledad Vel | last post by:
Hi All, i write this code: var sliderwidth=100; var sliderheight = 100; var div1 = document.createElement('div'); div1.setAttribute('id','d5'); div1.setAttribute('style',...
2
by: Guy Noir | last post by:
Hello all. I am new to Javascript but versed in JAva, c#, etc. I'm running into a problem and I'm hoping someone can point me in the right direction. I have 2 images (Up and down arrows) and...
1
by: colleen1980 | last post by:
Hi: I am trying to pull all the values from the listbox. But the ASP code shows only the last record. Needs help HTML <html> <head>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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,...

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.