SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: No parentNode?
Threaded View
-
Aug 4, 2007, 01:51 #1
- Join Date
- Sep 2004
- Location
- antwerp
- Posts
- 10
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No parentNode?
Hello,
I recently started to dip my toes into the DOM and Javascript but I ran into a problem. I get this error:
parent has no properties
[Break on this error] if(parent.lastChild == targetElement){
Code:function insertAfter(newElement, targetElement){ var parent = targetElement.parentNode; if(parent.lastChild == targetElement){ parent.appendChild(newElement); }else{ parent.insertBefore(newElement, targetElement.nextSibling); } } function contactCheck(){ if(!document.getElementById('contactform')) return false; function okimg(where){ var okimg = document.createElement('img'); okimg.setAttribute('alt', 'Correct'); okimg.setAttribute('src', '/media/img/form_good.gif'); okimg.setAttribute('class', 'ok'); okimg.setAttribute('id', where + 'ok'); insertAfter(okimg, where); } if(document.getElementById('c-name')){ document.getElementById('c-name').onchange = function(){ if(document.getElementById('c-name').value != ''){ okimg('c-name'); } } } }
Code:<dd> <input id="c-name" class="text" type="text" value="" name="c-name"/> </dd>
Bookmarks