ParentNode Of ParentNode Skipped If Tag Is Same

Dec 14, 2005

HTML Code:
<body id="body">
<p id="w">
<p id="x">
<p id="y">
<p id="z">
<input type="button" value="Check parent!" onclick="checkParent(this)" />
</p>
</p>
</p>
</p>
</body>

Code:
<script>
function checkParent(obj0){
alert(obj0.parentNode.parentNode.id);
}
</script>
When I click the button, it alerts "body" ( In FF and IE6 ). But I want that function to alert as "y" since the tag <p id="y"> is the parentNode.parentNode of <input>. The function somehow skips the tags

HTML Code:
<p id="w">
<p id="x">
<p id="y">

View 2 Replies


ADVERTISEMENT

Javascript ParentNode

Apr 2, 2006

An interesting thing is happening. My table doesnt have 'TBody', but
the elem.parentNode.tagName is returning 'TBody' where elem refers to
the 'tr' tag.

Shouldnt it be returning 'table' ?

<body>
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
</body>

Also, its adding html tag even if its not present in the document (if I
lookup parentNode of body). Is there a way to tell javascript not to be
intelligent? (because I am building an xpath and I want to extract the
exact xpath from the real-world-html-document)

View 14 Replies View Related

Better .parentNode Management

Mar 29, 2007

I would like to not have to write:
.parentNode.parentNode.parentNode.parentNode.parentNode

Instead I would like to just write something like this instead:
.parentNode(5)
to represent that there needs to be 5 .parentNode

View 5 Replies View Related

JQuery :: Get ParentNode And Then Div With Class?

May 25, 2010

I want to get the div with class "editrow" to change display and height when the div with class "col3" is clicked on the same li tag.

I have the following (not working) code.

<script
type
="text/javascript"
src

[Code]....

View 1 Replies View Related

Remove The Sibling Of $this.parentNode?

Apr 28, 2011

How can I remove the sibling of $this.parentNode?

Code:
input1[i].onclick = function()
{
var $this = this;

[Code].....

View 5 Replies View Related

Get ParentNode.insertBefore To Work In IE7?

Jan 30, 2010

This works fine in FF and Chrome, how can I get to work in IE7?

function insertAfter( referenceNode, newNode )
{
referenceNode.parentNode.insertBefore( newNode, referenceNode.previousSibling);
}

View 1 Replies View Related

Change The Parentnode For A Given Element?

Mar 21, 2009

How could I change the parentnode for a given element using Javascript?

View 1 Replies View Related

JQuery :: ParentNode Is Null Or Not An Object

Sep 30, 2009

I am getting this error on IE8; it is working nice on firefox, and I have to support IE. I found this page: [URL] And they identify as the problem occurring here: The error occurs in the 'install' function right here:

<quote from link>
var node = msg.jquery ? msg[0] : msg;
var data = {};
$(el).data('blockUI.history', data);

[Code].....

View 1 Replies View Related

Using ParentNode In Link To Edit Table Row?

May 11, 2009

I have been using parentNode to delete rows from a table when clicking a button using:this.parentNode.parentNode.rowIndex Now, I have another case where I want to determine the row number to edit the row. This time, however, I've decided to use a link on the first column of the row. Because I wasn't using a button, I assumed that I could simply remove one of the parentNode's in the function call. But when I click the link I am getting a javascript error saying the parentNode.rowIndex is null or not an object. Listed below is the code I'm using.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>

[code]....

View 2 Replies View Related

Way To Position A Dynamically Created <div> Inside A Specific ParentNode

Jun 30, 2009

Is there a way to position a dynamically created <div> inside a specific parentNode?

For example, if in my html code I have

<div id="test"></div>

When I create my dynamic <div>, can I created it to be within the above div? Or must it always be appended to the end?

View 1 Replies View Related

JQuery :: Microsoft JScript Runtime Error: 'parentNode' Is Null Or Not An Object

Jan 6, 2012

i am starting a new project using Visual Studio 2010 ad using the same jQuery filesofa previous project that didn't cause errors.Visaul Studio always raisesthe same error in jquery.min.js Microsoft JScript runtime error: 'parentNode' is null or not an object I click on "continue" for that error message and the page loads fine and I don't see the javascript error icon in the bottom left corner of IE. This really baffles me. When I launch the application using Firefox I don't get an error in Visual Studio. Does anyone have any tips on debugging this jquery.min.js ? Has anyone seen something similar. Just starting this project and I already lost 12 hours troubleshooting this problem. I've looked at the html code and I can't see anything that would cause an error Here is the HTML.

[Code]...

View 5 Replies View Related

This.parentNode - Access The Elements Of The Form Without Referring To Them By ID As The Whole Form Is Intended To Be Cloned

Feb 16, 2011

I've put together what I think is an illustration of my problem at [URL] Quite simply, I need to be able to access the elements of the form without referring to them by ID as the whole form is intended to be cloned. I intended to do this using parentNode and childNodes[] together with the 'this' keyword. My understanding of 'this' in this context is that it should refer to the HTML element calling the function, i.e. one of the radio button inputs. However this gives the error "Error: this.parentNode is undefined"

View 1 Replies View Related

JQuery :: Set A Cookie - Opening Slide Show Should Be Skipped ?

Jan 9, 2011

I am trying to set a cookie with jquery. The point of this cookie is to tell me if the person hasvisitedmy site before. If they have the opening slide show should be skipped. My problem is that I do not know how to do this.

The problem with my current code is that it sets the cookie but it should only set on the 2nd visit or...I need another way to count the visits to the page.

This is my code...then I hit a dead-end:

View 4 Replies View Related

Ajax :: First Function Call On Page Load Always Skipped

Oct 9, 2010

Trying to call the same Ajax function twice on initial load of the page, but only the second one executed. I try to load mainpage, and inside mainpage I try to use ajax to load content1.asp to div1 and content2.asp to div2.

Test scenario (based on the Situation below):
- Page loaded, 1st ajax function skipped, 2nd ajax function loaded
- Remarked 1st ajax function, then 2nd ajax function loaded
- Remarked 2nd ajax function, then 1st ajax function loaded
- Moved the 2nd ajax function to above 1st ajax function, the 2nd ajax function is skipped.

Conclusion:
- the 1st ajax function always skipped. But Why? How to ensure both ajax is called upon loading of the page?

Situation:
mainpage.asp
<div id="div1"></div>
<div id="div2"></div>
<script language="JavaScript1.2">
ajax('div1', 'GET', 'page1.asp');
ajax('div2', 'GET', 'page2.asp');
</script>

ajax.js -
function ajax(strDivID, strMethod, strURL){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById(strDivID).innerHTML=xmlhttp.responseText;
}}
xmlhttp.open(strMethod,strURL,true);
if (strMethod="POST"){
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
}xmlhttp.send();
}

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved