might consider using a filter to locate the elements between the hr's
and use wrapAll(), then remove the hr's
Liam Byrne wrote:
If you do what you're thinking, then every second content element would
be OUTSIDE of any <div>
What (I think) you need to do is:
FIRST <hr/> : OPEN DIV
LAST <hr/> : CLOSE DIV
EVERY IN-BETWEEN <hr/> CLOSE DIV FOLLOWED BY OPEN DIV
If you don't do all of those in a single step, however, I'd suspect
that the browser will detect an open, unclosed DIV and "interpret" it,
adding the closing div automatically.
L
Evert wrote:
Hi there,
I am a newbie at using jquery and now I stumbled upon a problem. With
Jquery I want to replace each <hr/> with a <div> opening
tag or a </
div> closing tag. This way I would like to place a large page of
content in different divs.
Now I have this code :
var counter = 0;
for(var i = 0; i < $('hr').size(); i++){
if(counter == 0){
$("hr:eq(i)").replaceWith("<div>");
counter++;
}else if(counter == 1){
$("hr:eq(i)").replaceWith("</div>");
counter = 0;
}
}
But it replaces every <hr/> with a open and close <div>
tag. Anyone
knows how I could get this working?
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database:
270.13.18/2243 - Release Date: 07/17/09 06:08:00
|