Replacing html tags

Having a table with id tag like below
<table id=tesTable>

If  screen size < 480px
Run a javascript to (
   Search tag for  table excluding id
  And replace with div)
   Keeps table tag

Any help with code for this is greatly appreciated
Who is Participating?
leakim971Connect With a Mentor PluritechnicianCommented:
With jQuery :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src=""></script>
<script language="javascript">
	$(document).ready(function() {
		$("table").each(function() {
			$(this).replaceWith("<div id=\"" + $(this).attr("id") + "\">" +  $(this).html() + "</div>") 
<table id="tesTable"><tr height="396"><td width="640">tesTable</td></tr></table>
<table id="notesTable"><tr><td>notesTable</td></tr></table>

Open in new window

And you're wanting to do this in what language?
zrazakAuthor Commented:
In javascript
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Any reason why the original markup can't lose the table?
zrazakAuthor Commented:
well I dont want to change the original code its for desktop website and want toreplace the table tags with div tags  for viewing purposes on mobile devices thus not technically replacing the actual code
It just seems like a hard way to do what should be a relatively easy job. Do you have a test page available for viewing?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.