Inserting a break in jquery

I have this code that breaks a table for mobile device what I am trying to accomplish is having a break or line feed between each row.  Any help with this is greatly appreciated.  Thanks
$(document).ready(function StripTable() {
if (screen.width > 800) {  // Windows 7 phone is 480px wide; if screen size is less than 800 best to have one column
    //Detected mobile else desktop
        $("td").each(function () {
            $(this).replaceWith("<div id=\"" + $(this).attr("id") + "\">" + $(this).html() + "</div>")

        });
        $("tr").each(function () {
            $(this).replaceWith("<div id=\"" + $(this).attr("id") + "\">" + $(this).html() + "</div>")
        });
        $("table").each(function () {
            $(this).replaceWith("<div id=\"" + $(this).attr("id") + "\">" + $(this).html() + "</div>")

        });
        // other option is to add row for every element in the table, 
        //      but then blank rows will be inserted when natural new row occurs
        
    }
});

Open in new window

zrazakAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
So if you have
<table id="table1">
<tr id="row1">
  <td id="r1cell1">Row 1 cell 1</td>
  <td id="r1cell2">Row 1 cell 2</td>
</tr>
<tr id="row2">
  <td id="r2cell1">Row 2 cell 1</td>
  <td id="r2cell2">Row 2 cell 2</td>
</tr>
</table>

you will get

<div id="table1">
<div id="row1">
  <div id="r1cell1">Row 1 cell 1</div>
  <div id="r1cell2">Row 1 cell 2</div>
</div>
<div id="row2">
  <div id="r2cell1">Row 2 cell 1</div>
  <div id="r2cell2">Row 2 cell 2</div>
</div>
</div>

you hope?

Then why have a table at all?



zrazakAuthor Commented:
This will allow to break a table of original website to not be of tabular form.  Thus a check will check if mobile device and runs code to render the table to display properly for mobile devices.  Since mobile does not display table well.
Michel PlungjanIT ExpertCommented:
so what exactly is the problem?

$("tr").each(function () {
            $(this).replaceWith("<div id=\"" + $(this).attr("id") + "\">" + $(this).html() + "</div><br style=\"clear:all\" />")
        });
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Michel PlungjanIT ExpertCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zrazakAuthor Commented:
Mplungjan can you explain this
Michel PlungjanIT ExpertCommented:
can I explain what?

I just added a break to your script after each row
zrazakAuthor Commented:
some good info but not complete
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JScript

From novice to tech pro — start learning today.