[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Is there such a thing as AppendSibling?

bit-naughty

4/26/2016 6:10:00 AM

I know about AppendChild, but if I say, have a <div> and I want another <div> *next* to it to appear when a particular button is clicked - i.e. _it's at the same level in the DOM tree_ !!! , then what do I do?


Thanks.
18 Answers

Jake Jarvis

4/26/2016 7:01:00 AM

0

Am 26.04.2016 um 08:09 schrieb bit-naughty@hotmail.com:
> I know about AppendChild, but if I say, have a <div> and I want another <div> *next* to it to appear when a particular button is clicked - i.e. _it's at the same level in the DOM tree_ !!! , then what do I do?
>
>
> Thanks.
>

Go up one level to the parent element and use the insertBefore(newChild,
refChild) method.

JJ

4/26/2016 12:05:00 PM

0

On Tue, 26 Apr 2016 09:01:13 +0200, Jake Jarvis wrote:
> Am 26.04.2016 um 08:09 schrieb bit-naughty@hotmail.com:
>> I know about AppendChild, but if I say, have a <div> and I want another <div> *next* to it to appear when a particular button is clicked - i.e. _it's at the same level in the DOM tree_ !!! , then what do I do?
>>
>>
>> Thanks.
>>
>
> Go up one level to the parent element and use the insertBefore(newChild,
> refChild) method.

Or insertAdjacentHTML(). Whichever is applicable.

Thomas 'PointedEars' Lahn

4/26/2016 3:50:00 PM

0

JJ wrote:

> On Tue, 26 Apr 2016 09:01:13 +0200, Jake Jarvis wrote:
>> Am 26.04.2016 um 08:09 schrieb bit-naughty@hotmail.com:
>>> I know about AppendChild, but if I say, have a <div> and I want another
>>> <div> *next* to it to appear when a particular button is clicked - i.e.
>>> _it's at the same level in the DOM tree_ !!! , then what do I do?
>>> Thanks.
>> Go up one level to the parent element and use the insertBefore(newChild,
>> refChild) method.
>
> Or insertAdjacentHTML(). Whichever is applicable.

insertAdjacentHTML() is proprietary, inefficient, and error-prone; and it is
obsolete since IE/MSHTML 5.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.

JJ

4/27/2016 5:15:00 AM

0

On Tue, 26 Apr 2016 17:49:49 +0200, Thomas 'PointedEars' Lahn wrote:
>
> insertAdjacentHTML() is proprietary, inefficient, and error-prone; and it is
> obsolete since IE/MSHTML 5.

True, but Chromium and Firefox support it regardless. You should tell them
that.

Efficiency and flawlessness would depend on the implementation, not the
function specifications.

And IE still support it until its last version. Surely you meant Edge
instead of IE?

Stefan Weiss

4/27/2016 9:28:00 AM

0

JJ wrote:
> On Tue, 26 Apr 2016 17:49:49 +0200, Thomas 'PointedEars' Lahn wrote:
>>
>> insertAdjacentHTML() is proprietary, inefficient, and error-prone; and it is
>> obsolete since IE/MSHTML 5.
>
> True, but Chromium and Firefox support it regardless. You should tell them
> that.
>
> Efficiency and flawlessness would depend on the implementation, not the
> function specifications.
>
> And IE still support it until its last version. Surely you meant Edge
> instead of IE?

Edge and IE both support it (as do all of the other major browsers). I can't
find any indication that this method has ever been marked as obsolete. It
doesn't look particularly inefficient or error-prone to me. Interesting to
see such unsubstantiated claims from someone who frequently insists that
others have to "cite evidence".

- stefan

Cezary Tomczyk

4/27/2016 12:07:00 PM

0

On 26/04/2016 16:49, Thomas 'PointedEars' Lahn wrote:
> JJ wrote:
>
>> On Tue, 26 Apr 2016 09:01:13 +0200, Jake Jarvis wrote:
>>> Am 26.04.2016 um 08:09 schrieb bit-naughty@hotmail.com:
>>>> I know about AppendChild, but if I say, have a <div> and I want another
>>>> <div> *next* to it to appear when a particular button is clicked - i.e.
>>>> _it's at the same level in the DOM tree_ !!! , then what do I do?
>>>> Thanks.
>>> Go up one level to the parent element and use the insertBefore(newChild,
>>> refChild) method.
>>
>> Or insertAdjacentHTML(). Whichever is applicable.
>
> insertAdjacentHTML() is proprietary, inefficient, and error-prone; and it is
> obsolete since IE/MSHTML 5.

Based on:

*
https://w3c.github.io/DOM-Parsing/#widl-Element-insertAdjacentHTML-void-DOMString-position-DOMS...
* https://msdn.microsoft.com/en-us/library/ms536452%28v=vs....
*
https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAd...

I don't think so it's obsolete.

--
Cezary Tomczyk
http://www.ct...

Michael Haufe (\"TNO\")

4/27/2016 1:42:00 PM

0

On Wednesday, April 27, 2016 at 7:07:34 AM UTC-5, Cezary Tomczyk wrote:
> On 26/04/2016 16:49, Thomas 'PointedEars' Lahn wrote:
> > JJ wrote:
> >
> >> On Tue, 26 Apr 2016 09:01:13 +0200, Jake Jarvis wrote:
> >>> Am 26.04.2016 um 08:09 schrieb bit-naughty [...]:
> >>>> I know about AppendChild, but if I say, have a <div> and I want another
> >>>> <div> *next* to it to appear when a particular button is clicked - i.e.
> >>>> _it's at the same level in the DOM tree_ !!! , then what do I do?
> >>>> Thanks.
> >>> Go up one level to the parent element and use the insertBefore(newChild,
> >>> refChild) method.
> >>
> >> Or insertAdjacentHTML(). Whichever is applicable.
> >
> > insertAdjacentHTML() is proprietary, inefficient, and error-prone; and it is
> > obsolete since IE/MSHTML 5.
>
> Based on:
>
> *
> https://w3c.github.io/DOM-Parsing/#widl-Element-insertAdjacentHTML-void-DOMString-position-DOMS...
> * https://msdn.microsoft.com/en-us/library/ms536452%28v=vs....
> *
> https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAd...
>
> I don't think so it's obsolete.

Don't reference a Draft if you are making an argument about what is standard.

<https://www.w3.org/TR/DOM-Parsing/#widl-Element-insertAdjacentHTML-void-DOMString-position-DOMStrin...

Evertjan.

4/27/2016 1:53:00 PM

0

"Michael Haufe (TNO)" <tno@thenewobjective.com> wrote on 27 Apr 2016 in
comp.lang.javascript:
> On Wednesday, April 27, 2016 at 7:07:34 AM UTC-5, Cezary Tomczyk wrote:
>> I don't think so it's obsolete.
>
> Don't reference a Draft if you are making an argument about what is
> standard.

Not obsolete does not equal being standard.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Christoph M. Becker

4/27/2016 2:00:00 PM

0

Michael Haufe (TNO) wrote:

> Don't reference a Draft if you are making an argument about what is standard.
>
> <https://www.w3.org/TR/DOM-Parsing/#widl-Element-insertAdjacentHTML-void-DOMString-position-DOMStrin...

From the linked document (emphasis mine):

| This is a *draft* document and may be updated, replaced or obsoleted |
by other documents at any time. It is inappropriate to cite this
| document as other than work in progress.

:)

--
Christoph M. Becker

Michael Haufe (\"TNO\")

4/27/2016 5:48:00 PM

0

On Wednesday, April 27, 2016 at 9:00:14 AM UTC-5, Christoph M. Becker wrote:
> Michael Haufe (TNO) wrote:
>
> > Don't reference a Draft if you are making an argument about what is standard.
> >
> > <https://www.w3.org/TR/DOM-Parsing/#widl-Element-insertAdjacentHTML-void-DOMString-position-DOMStrin...
>
> From the linked document (emphasis mine):
>
> | This is a *draft* document and may be updated, replaced or obsoleted |
> by other documents at any time. It is inappropriate to cite this
> | document as other than work in progress.
>
> :)

ACK.

<https://www.w3.org/TR/#...