Solved

parentNode from an <a> in a td.

Posted on 2006-06-24
2
661 Views
Last Modified: 2008-03-17
Howdy.

I got this structure: <td style="background-color: #000000"><a href="javascript:Pick(this);"></a></td>

I want to get the background-color value with JS, I tried to access the TD by:

function Pick(color) {
  alert(color.parentNode);
}

But it returns undefined.

Help would be appreciated.
0
Comment
Question by:shmulik15
2 Comments
 
LVL 25

Accepted Solution

by:
devic earned 125 total points
ID: 16976431
<script>
function Pick(obj)
{
  alert(obj.parentNode.style.backgroundColor);
}
</script>
<table>
      <td style="background-color: #000000"><a href="#" onclick="Pick(this); return false;">aaa</a></td>
</table>      
0
 

Author Comment

by:shmulik15
ID: 16976441
Thanks devic.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question