/    Sign up×
Community /Pin to ProfileBookmark

accessing html of table row

Hey y’all!

Does anyone know a way of referring to the html of an entire table row – from the opening <tr> to the closing </tr> ?

I’m wrote a script using Microsoft’s innerHTML function that can do this, but I’m looking for a cross-browser DOM solution instead.

Any takers…? ?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@swonJan 11.2003 — how do you use the microsoft specificated:

document.YourElement.rows[rowsnumber].innerHTML ?
Copy linkTweet thisAlerts:
@AtomicPenguinauthorJan 11.2003 — Kinda like this:

<table>

<tr><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td></tr>

<tr id="chicken"><td>contents here.<img src="./example.gif"></td></tr>

<tr><td>&nbsp;</td></tr>

</table>

<input type="button" onclick="javascript: alert(document.all['chicken'].innerHTML);">



  • - I stuck the <img> tag in the row's <td> just to show how innerHTML returns the HTML, not just the text.
  • Copy linkTweet thisAlerts:
    @swonJan 11.2003 — Okay, the DOM version is:


    document.getElementById("chicken").innerHTML
    Copy linkTweet thisAlerts:
    @AtomicPenguinauthorJan 12.2003 — Hey, thanks Swon!

    Mind if I ask another one? I have this code which works fine in IE, but not in Mozilla or Netscape 6.

    var tableElement = document.getElementById("t");

    if (tableElement.rows(row).cells(0).firstChild.getAttribute ("checked") == true) {

    alert("checked");

    }


    I'm having trouble identifying precisely which spot the other browsers don't like.

    All it's doing is checking to see if the relevant input=checkbox element is checked or not.

    Sorry if these questions are rudimentary. ?
    Copy linkTweet thisAlerts:
    @swonJan 12.2003 — Are you using forms? It might be the best when you get the checked boxes via the form object.

    Post an example of your code.
    ×

    Success!

    Help @AtomicPenguin spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...