Karl Swedberg wrote:
here we go again... :-)
I replied to a similar question regarding specifying an ID inside of a
class a few days ago.
same thing applies to ID inside an ID...
This paragraph from the reference section of the upcoming Learning
jQuery book might help explain why someone would want or need to
preselect a class first. It discusses specifying a tag name rather
than a class, but the same principle applies:
It might not be immediately clear why someone might want to specify a
tag name associated with a particular id, since that id needs to be
unique anyway. However, some situations in which parts of the DOM are
user-generated may require a more specific expression to avoid false
positives. Furthermore, when the same script is run on more than one
page, it might be necessary to identify the id's element, since the
pages could be associating the same id with different elements. For
example, Page A might have <h1 id='title'> while Page B has <h2
id='title'>.
Hope that makes sense.
Makes perfect sense. Another example to illustrate this is a result from
a search.
If there's nothing found from the search you maybe render a paragraph
like this:
<p id="search-result">
<em>No items found. Please try another search.</em>
</p>
Whereas for a result with found items you would use a list:
<ul id="search-result">
...
</ul>
Presentation and maybe behavioral enhancement maybe based off the type:
p#search-result {
/* some styles */
}
ul#search-result {
/* some other styles */
}
Which is nothing else than relying on an element with a certain id
nested in another one in one situation opposed to some other structure
in a slightly different case.
--Klaus