Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Replacing html tags

Posted on 2011-03-10
6
Medium Priority
?
180 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
Independent Software Vendors: 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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…

704 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