Solved

parentNode from an <a> in a td.

Posted on 2006-06-24
2
659 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

773 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