How to add an image to the header of a table

Discussion in 'Javascript' started by Stefan Mueller, Dec 18, 2009.

  1. I've a html table with a header row and several columns. If I click on
    the header of a column the function 'clicked_column(var_this)' gets
    called.
    Because I'm able within that function to change just on the clicked
    header the mousepointer with 'var_this.style.cursor = "crosshair";' to
    a cross I think that there must by also a way to add an image to the
    existing header (<header title> <image>).

    Does someone know if this is really possible and if yes how it can be
    done?
     
    Stefan Mueller, Dec 18, 2009
    #1
    1. Advertising

  2. Stefan Mueller wrote:

    > [...] I think that there must by also a way to add an image to the
    > existing header (<header title> <image>).


    There is. RTFM.

    > Does someone know if this is really possible and if yes how it can be
    > done?


    Yes.

    <http://www.catb.org/~esr/faqs/smart-questions.html>


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, Dec 18, 2009
    #2
    1. Advertising

  3. Great to know that it's possible.

    I know that I can change the header title with
    var_this.childNodes.item(0).data = "New Text";
    But is it really also possible to change the image in the header
    title?

    Please give me a hint.
     
    Stefan Mueller, Dec 19, 2009
    #3
  4. Stefan Mueller

    David Mark Guest

    On Dec 19, 1:42 pm, Stefan Mueller <> wrote:
    > Great to know that it's possible.
    >
    > I know that I can change the header title with
    >   var_this.childNodes.item(0).data = "New Text";


    Sort of. It depends on the content of the node (i.e. it could contain
    multiple text nodes). For example, some browsers create "extra" nodes
    for extraneous white space.

    <th>
    This might be the first child node
    </th>

    <th>This is the first child node</th>

    > But is it really also possible to change the image in the header
    > title?
    >
    > Please give me a hint.


    Here's two:-

    https://developer.mozilla.org/En/DOM/Document.createElement
    https://developer.mozilla.org/En/DOM/Node.appendChild
     
    David Mark, Dec 19, 2009
    #4
  5. David, many thanks for your hints.
    It works great!
     
    Stefan Mueller, Dec 20, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sean Jorden
    Replies:
    1
    Views:
    609
    laurie
    Aug 19, 2003
  2. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,395
    Kartic
    Jan 26, 2005
  3. mlt
    Replies:
    2
    Views:
    881
    Jean-Marc Bourguet
    Jan 31, 2009
  4. hansiman

    Image in header column (not replacing column header text)

    hansiman, Feb 5, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    318
    hansiman
    Feb 7, 2004
Loading...

Share This Page