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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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.