Solved

Replacing html tags

Posted on 2011-03-10
6
178 Views
Last Modified: 2012-05-11
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)
}
Else
   Keeps table tag

Any help with code for this is greatly appreciated
0
Comment
Question by:zrazak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:Webmonkey
ID: 35100368
And you're wanting to do this in what language?
0
 

Author Comment

by:zrazak
ID: 35100433
In javascript
0
 
LVL 4

Expert Comment

by:RawElements
ID: 35108484
Any reason why the original markup can't lose the table?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:zrazak
ID: 35108855
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
0
 
LVL 4

Expert Comment

by:RawElements
ID: 35109756
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?
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35113658
With jQuery :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script language="javascript">
	$(document).ready(function() {
		$("table").each(function() {
			$(this).replaceWith("<div id=\"" + $(this).attr("id") + "\">" +  $(this).html() + "</div>") 
		});
	});
</script>
</head>
<body>
<table id="tesTable"><tr height="396"><td width="640">tesTable</td></tr></table>
<br/>
<table id="notesTable"><tr><td>notesTable</td></tr></table>
</body>
</html>

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question