开发者

How to change source order of <div> in less steps/automatically?

开发者 https://www.devze.com 2023-01-01 17:58 出处:网络
How can I do this task automatically. I need to change source order of the divs, which has same id in above 100 pages.

How can I do this task automatically. I need to change source order of the divs, which has same id in above 100 pages.

I created an example:

This is default condition

<div class="identification">  <div class="number">Number 1</div> </div>
<div class="identification">  <div class="number">Number 2</div> </div>
<div class="identification">  <div class="number">Number 3</div> </div>
<div class="identification">  <div class="number">Number 4</div> </div>
<div class="identification">  <div class="number">Number 5</div> </div>
<div class="identification">  <div class="number">Number 6</div> </div>
<div class="identification">  <div class="number">Number 7</div> </div>

I need it like this

<div class="identification">  <div class="number">Number 1</div> </div>
<div class="identification">  <div class="number">Number 3</div> </div>
<div class="identification">  <div class="number">Number 2</div> </div>
<div class="identification">  <div class="number">Number 7</div> </div>
<div class="identification">  <div class="number">Number 4</div> </div>
<div class="identification">  <div class="number">Number 5&l开发者_StackOverflow中文版t;/div> </div>
<div class="identification">  <div class="number">Number 6</div> </div>

Is the manual editing only option? I use Dreamweaver.

I have to do this change in HTML source permanently.


Edit: (it's just example)

The fix things are, total div are 7 and every container div has same class="identification"


Breathe deep and start manual editing. Take pauses of 5 minutes on every 10 minutes to avoid that you get freaked out. You'll finish in a hour or two. At least, in less time than figuring the regex solution for this.


The easiest solution would be to do a single Find & Replace, searching for the entire menu as it is now, and replacing it with the entire menu as you want it to be. This ignores completely the actual changes ("I want to move this div up here and that one down there"), and gets the job done in one operation, covering all 100 pages.

Alternatively, you can do several smaller Find & Replace operations:

Replace <div class="identification"> <div class="number">Number 3</div> </div> with <div class="identification"> <div class="number">Number 6</div> </div>

Replace <div class="identification"> <div class="number">Number 2</div> </div> with two lines:

<div class="identification">  <div class="number">Number 3</div> </div>
<div class="identification">  <div class="number">Number 2</div> </div>


Well you could move it around using javascript, or you could delete list and replace it using javascript as well.

You can use jQuery detach(), remove() and append()/appendTo() methods for this kind of manipulation.


is it always the same number you need to replace? In dreamweaver you could do a find and replace in all files in a folder. Replace "Number 6" with "Number X" then replace "Number 4" with "Number 6" then finally replace "Number X" with "Number 4"

saves you writing a program to do it

0

精彩评论

暂无评论...
验证码 换一张
取 消