- From: Jasper Bryant-Greene <jasper@bryant-greene.name>
- Date: Sun, 04 Sep 2005 15:17:13 +1200
S. Mike Dierken wrote: >>Yes, but it still shouldn't be empty, how can you link to part of a page > > that's nothing? > You mean 'why' rather than how? I suppose if you had a system that allowed > your boss to tell you "add a paragraph of blurbiage after paragraph 3 and > before paragraph 4", how you you reference that point between existing > elements? Certainly not with an empty <a> element, that's for sure. In this HTML fragment: | <body> | <p>First paragraph...</p> | <p>Second paragraph...</p> | <p>Third paragraph...</p> | <p>Fourth paragraph...</p> | </body> Some JS like this: | var body = document.getElementsByTagName('body')[0]; | var fourthParagraph = body.getElementsByTagName('p')[3]; | | var newParagraph = document.createElement('p'); | newParagraph.appendChild(document.createTextNode('New paragraph')); | | body.insertBefore(newParagraph, fourthParagraph); Would do exactly that. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/
Received on Saturday, 3 September 2005 20:17:13 UTC