On Sun, Sep 13, 2009 at 5:53 PM, limodou <[email protected]> wrote: > Today I try to use nth-child selector to get the last child element > from a div, but I failed, and I can't get the last but the first, I > don't know why? > > Here is a test: > > HTML file: > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" > "http://www.w3.org/TR/html4/strict.dtd"> > <html> > <head> > <title>Hello World</title> > <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> > <script type="text/javascript" src="mootools-1.2.3-core.js"></script> > </head> > <body> > <div id="test"> > <div class="child" id="1"> > <div class="label">1</div> > <div class="content">1</div> > </div> > <div class="child" id="2"> > <div class="label">2</div> > <div class="content">2</div> > </div> > <div class="child" id="3"> > <div class="label">3</div> > <div class="content">3</div> > </div> > <div class="child" id="4"> > <div class="label">4</div> > <div class="content">4</div> > </div> > </div> > </body> > </html> > > Testing: > > Open firebug in Firefox, input below lines: > >>>> a = $('test') > <div id="test"> >>>> a.getElement(':nth-child(last)') > <div class="content"> >>>> a.getElement(':nth-child(last)').get('html') > "1" > > So what I want is to get the <div class="child" id="4">, but I got > <div class="content">1</div>, and I'm confused, and how to get the > first level child element (<div class="child" id="4">)? >
I found I should use getLast(). Sorry for boring you. -- I like python! UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/ UliWeb <<simple web framework>>: http://uliwebproject.appspot.com My Blog: http://hi.baidu.com/limodou
