#1 2007-09-01 08:52:20
- GP Michal
- Member

- From: Nashville TN
- Registered: 2007-08-30
- Posts: 82
- I've been thanked 1 times.
-
Question on the "ID" attribute
Hi all:
Quick question about the ID attribute. I've been reading the the tutorials at w3schools and have looked at a few examples but I can't figure out for the life of me why it may be useful or important to use this attribute. I know that it's an unique identifier but I guess I don't know of a need for this type of identifier. Can someone please give me a brief explanation and perhaps an example?
Thanks,
GP
Offline
#2 2007-09-01 10:13:40
- TA
- Banned
- Registered: 2004-11-25
- Posts: 4913
- I've been thanked 39 times.
-

Re: Question on the "ID" attribute
W3C schools is quite intense, and they do have an area which defines that somewhat -- however; the ID attribute is associated with XHTML and CSS ... go thru some of these sites to read more about it.
Offline
#3 2007-09-02 11:00:14
- Northie
- Moderator

- From: Yorkshire, UK
- Registered: 2006-08-19
- Posts: 2629
- I've been thanked 63 times.
-

Re: Question on the "ID" attribute
IDs are great because they allow you to give a unique ID to every element in the DOM, if you wish.
The most obvious reason is CSS selectors; you know exactly which elements will be affected beacuse there's only one per page
Where IDs really come in handy is DOM manipulation. - [old fashion] javascript uses the function getElementById() to interrogate the DOM.
Although new javascript libraries (such as jquery) allow you to use Xpath selectors to get DOM elements; getElementById is still the base root of the idea.
So now you're asking "why would i want to use javascript to interrogate the DOM?"
That's a pretty easy answer too - when working with a lot of content, custom animations, server applications, XML and / or AJAX it becomes a necessity to have some computer-based intelligence about the static HTML.
HTML doesn't do anything apart from structure the page; and if you want to play with that structure you need to have some client side (javascript) software that bridges the gap between user and plain text HTML
Here's an example of some DOM manipulation: http://xeneco.co.uk/extjs
Now taking free-lance inquiries; Please contact me for more details
Internet Marketing Books
Promote Yourself on Site Reference!
Offline
#4 2007-09-03 09:50:08
- GP Michal
- Member

- From: Nashville TN
- Registered: 2007-08-30
- Posts: 82
- I've been thanked 1 times.
-
Re: Question on the "ID" attribute
OK...Northie. I'm really showing my "noobieness" now. Let's start with the meaing of "DOM". What does it stand for? I guess I have a looooonnnnnggggg way to go. Especially since I"m leaving Storesonline and will want to build my owm e-Commerce site.
TA...thanks for the link. I'll do a little study there. Perhaps I'll start understanding more.
Offline
#5 2007-09-03 16:15:17
- Northie
- Moderator

- From: Yorkshire, UK
- Registered: 2006-08-19
- Posts: 2629
- I've been thanked 63 times.
-

Re: Question on the "ID" attribute
DOM - Document Object Model
it's the node tree of any given webpage; ie how the elements are nested, etc
nodes can have attributes, with values, and content.
eg
Code: html
<div id='menu'>
<ul>
<li><a href='#'>link</a></li>
<li><a href='#'>link</a></li>
<li><a href='#'>link</a></li>
<li><a href='#'>link</a></li>
</ul>
</div>
the div has an id attribute with the value 'menu'
[Xpath DOM example]
a link can be indentified by #menu/ul/li/a (this selects the node)
#menu/ul/li/a/@href gives the value of the link, etc etc
The DOM is how a computer sees a web page, and you can play with it if you know how. element IDs form the basis of how one does this
Now taking free-lance inquiries; Please contact me for more details
Internet Marketing Books
Promote Yourself on Site Reference!
Offline
#6 2007-09-03 19:29:36
- GP Michal
- Member

- From: Nashville TN
- Registered: 2007-08-30
- Posts: 82
- I've been thanked 1 times.
-
Re: Question on the "ID" attribute
Thanks, Northie. I'll do some more studying. I really do appreciate the help. I'm kind of curious about something. You're the 2nd person on this forum that's used some type of software that has that familiar header with the orange background in your example screen shot. Another person on here uses a similar orange header screen shot when he shows validation errors. What software is this?
GP
Offline
#7 2007-09-04 07:48:39
- MarkCCDC
- Moderator

- From: Deland, FL
- Registered: 2005-10-25
- Posts: 1270
- I've been thanked 20 times.
-

Re: Question on the "ID" attribute
GP Michal wrote:
Thanks, Northie. I'll do some more studying. I really do appreciate the help. I'm kind of curious about something. You're the 2nd person on this forum that's used some type of software that has that familiar header with the orange background in your example screen shot. Another person on here uses a similar orange header screen shot when he shows validation errors. What software is this?
GP
Are you talking about something like this:
Code:
Help! I'm in a box! With an orange header!
If so, there isn't anything special going on. When you are replying and/or creating a new topic on the forums, you are given formatting options at the top of the text box.
The formatting option that creates the "familiar header with an orange background" is the [ c o d e ] - [ / c o d e ]. (Without all those spaces).
Offline
| Never |
- Sponsored Results
|
|