Simple first-child js?
- by Glister
Searching for a simple first-child detection via javascript (no framework).
It should add some class for the first child of the element. Like a css-hacks for ie, but in javascript and for a html file.
Must work similar to :first-child
When I say no framework, I mean some code like this:
<script type="text/javascript">document.documentElement.id = "js"</script>
For example:
<div class="terms">
<dl>
<dt>Term 1 name</dt>
<dd>Term 1 description</dd>
</dl>
<dl>
<dt>Term 2 name</dt>
<dd>Term 2 description</dd>
</dl>
<dl>
<dt>Term 3 name</dt>
<dd>Term 3 description</dd>
</dl>
</div>
Three <dl>, the first one includes Term 1.
This css won't work in IE6, thats why I'm searching for a javascript solution. CSS-hacks are not allowed.
.terms dl:first-child { float: right; }