SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    bahrain
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up putting style by js

    i m putting in table row this "style="display:none;" .
    i m getting error on its event onclick().how can i make style="display:inline;" in event by js.
    its urgent plzzz.....
    regards
    phphelp

  2. #2
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    onclick()="this.style.display=inline" ?

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i m putting in table row this "style="display:none;"
    how can i make style="display:inline;" in event by js.
    If you know one thing about styling html, it should be: don't put styles inline in the html. Instead, you can set the .className property of a table row, and set the css style:
    Code:
    <style type="css/text">
    
    .hide{display:none}
    
    </style>
    Code:
    function tr_onclick(trReference)
    {
           this.className = "hide";
    }
    Code:
    <tr onclick="tr_onclick(this)">
    When the keyword 'this' is used inside an html element, it is a reference to the element.

  4. #4
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may wish to note that inline is not the appropriate default display property for a table row. IE, if queried, will report the default display value as 'block', while both Moz and Opera will report 'table-row' (the W3C-sanctioned value).

    This should serve to clarify:

    Code:
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
      <title>Untitled</title>
      <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
      </head>
      <body>
      <table>
      <tr id="tst_tr">
      <td>
     <a href="#" onclick="alert(document.getElementById('tst_tr').currentStyle? document.getElementById('tst_tr').currentStyle.display : window.getComputedStyle(document.getElementById('tst_tr'),null).display); return false;">tr display test</a>
      </td>
      </tr>
      </table>
      </body>
      </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •