Solved

Replacing html tags

Posted on 2011-03-10
6
169 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
6 Comments
 
LVL 6

Expert Comment

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

Author Comment

by:zrazak
Comment Utility
In javascript
0
 
LVL 4

Expert Comment

by:RawElements
Comment Utility
Any reason why the original markup can't lose the table?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:zrazak
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jquery, html5 UI 1 46
Responsive CSS question 2 37
Windows 10 bookmarks html file 6 26
Return data with AJAX, JQUERY and PHP 13 24
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now