Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 785561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:53:57+00:00 2026-05-14T20:53:57+00:00

Is there an easy way to loop through all td tags and change them

  • 0

Is there an easy way to loop through all td tags and change them to th? (etc).

My current approach would be to wrap them with the th and then remove the td, but then I lose other properties etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:53:58+00:00Added an answer on May 14, 2026 at 8:53 pm

    Completely untested, but giving this a whirl:

    $("td").each(function(index) {
      var thisTD = this;
      var newElement = $("<th></th>");
      $.each(this.attributes, function(index) {
        $(newElement).attr(thisTD.attributes[index].name, thisTD.attributes[index].value);
      });
      $(this).after(newElement).remove();
    });
    

    I’m looking and looking at it, and I can’t think of a reason why it wouldn’t work!

    1) loop through each td element

    2) create a new th element

    3) for each of those td’s, loop over each of its attributes

    4) add that attribute and value to the new th element

    5) once all attributes are in place, add the element to the DOM right after the td, and remove the td

    Edit: works fine: http://jsbin.com/uqofu3/edit

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a quick question. Is there way to easy loop through System.Collections.Generic.Dictionary via
Is there an easy way to loop through the values of an array using
Is there a way I can loop through the set of classes in a
I'm iterating through an array in ruby with each. Is there an easy way
I'm wondering if there's an easy way to iterate through a fd_set? The reason
Is there easy way to send email notification with cruise control? I Was reading
Is there any easy way to exchange the position of 2 elements - or
Is there an easy way to add shadows in opengl-es 1.x? Or only in
Is there an easy way to migrate a hosted LAMP site to Amazon Web
Is there an easy way how can I get in C char * from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.