Solved

CSS with javascript code that draw a border for table's row.

Posted on 2007-03-19
2
528 Views
Last Modified: 2010-05-18
Hi, I need CSS with javascript code that draw a border for table's row(Please note row and not cell).
0
Comment
Question by:Abdu_Allah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
stanscott2 earned 500 total points
ID: 18751137
Say you have this table:

<table id="myTable">
     <tr>
          <td></td>
     </tr>
     <tr>
         <td></td>
     </tr>
</table>

And you want a border around the second row.  Use this:

function setBorder() {
     var rowToSet = document.getElementById("myTable").rows[1];
     rowToSet.style.border = '2px solid black';
}
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 18751384
Are you sure that works?! it does not work with me: here is my entire page:

<HTML>
<HEAD>
 <script type="text/javascript">
      function setborder(){
      var rowToSet = document.getElementById("myTable").rows[1];
     rowToSet.style.border = '2px solid black';
     }
</script>
</HEAD>
<BODY onload="myfunction">

<table id="myTable"  >
     <tr >
          <td>row 1</td>
     </tr>
     <tr>
         <td>row 2</td>
     </tr>
     <input type="button" onclick="setborder()" value="test" />
</table>
</BODY>
</HTML>


0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

734 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