Jump to content

Javascript Div inline?


kimmieblob

Recommended Posts

IM trying to show some divs in a certain order. i want to show the first div twice then the second im using this

and this just goes straight to the second div, i need it like this click div1, click div1, click div 2

<html>
<head>
<script language="JavaScript">
var oldHistLength = history.length;
setInterval ( "checkHistory()", 100 );


function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}


function checkHistory() {
if (oldHistLength != history.length)
   {
   setVisibility('div1', 'none');
   setVisibility('div2', 'inline');
   oldHistLength = history.length;
   }
   }
</script>
</head>

<body>

<div align="center" id="div2" style="position:center; display:none">some content</div>

<div align="center" id="div1">some content i want to show twice</div>

Link to comment
https://forums.phpfreaks.com/topic/219352-javascript-div-inline/
Share on other sites

Hi Kimmi ,

 

I don't get Your Question Clear .... But I feel You like to Repeat the same Content Twice, I mean " some content i want to show twice",

So if you Use jQuery 1.4.x You can implement same using like this code :

<html>
<head>
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script type="text/javascript">
      $(document).ready(function() {
      $("#div1").clone().appendTo("#div1");
      });
</script>
</head>
<body >
<div align="center" id="div2" style="position:center; display:none">some content</div>
<div align="center" id="div1">some content i want to show twice</div>

 

Regards

Anes P.A  :D

logicslab,

 

That's going to result in two elements with the ID "div1", with the second appended as a child node of the first. Effectively resulting in the following HTML:

 

<div align="center" id="div1">
    some content i want to show twice
    <div align="center" id="div1">some content i want to show twice</div>
</div>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.