Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] To DOM or not -- calendar popup


  • From: nick at nickfitz.co.uk (Nick Fitzsimons)
  • Subject: [Javascript] To DOM or not -- calendar popup
  • Date: Wed Mar 29 14:16:40 2006

Steve Clay wrote:
> Wednesday, March 29, 2006, 1:58:48 PM, Bill Moseley wrote:
> 
>>2) or in the script search for the input field and then append the
>><img>  to the field's parent node list?[1]
> 
> 
> var myInput = document.getElementById('myInput');
> var myImg = document.createElement('img');
> 
> if (myInput.nextSibling) {
>     myInput.parentNode.insertBefore(myImg, myInput.nextSibling);
> } else {
>     myInput.parentNode.appendChild(myImg);
> }

Steve: there's no need for the if/else test for nextSibling; if the 
second argument to "insertBefore" is null then it acts like 
"appendChild" anyway. See:
<http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core.html#ID-952280727>

Regards,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/