1
我有以下的HTML。Mootools注入代碼修改它。每個
<ul>
<li>
<label id="firstswitch-lbl" class="hasTip">My First Selector:</label>
<select id="first_switch" class="switch">
<option value="0">Enable</option>
<option selected="selected" value="1">Disable</option>
</select>
</li>
<li>
<label id="first_title-lbl" class="hasTip">First Select:</label>
<input id="first_title" class="text" type="text" size="3" value="50">
</li>
<li>
<label id="secondswitch-lbl" class="hasTip">My Second Selector </label>
<select id="second_switch" class="switch">
<option value="0">Enable</option>
<option selected="selected" value="1">Disable</option>
</select>
</li>
<li>
<label id="second_title-lbl" class="hasTip">Second Select:</label>
<input id="second_title" class="text" type="text" size="3" value="100">
</li>
<li>
<label id="thirdswitch-lbl" class="hasTip">My Third Selector </label>
<select id="third_switch" class="switch">
<option value="0">Enable</option>
<option selected="selected" value="1">Disable</option>
</select>
</li>
<li>
<label id="third_title-lbl" class="hasTip">Third Select:</label>
<input id="third_title" class="text" type="text" size="3" value="200">
</li>
<li>
<label id="fourthswitch-lbl" class="hasTip">My Fourth Selector </label>
<select id="fourth_switch" class="switch">
<option value="0">Enable</option>
<option selected="selected" value="1">Disable</option>
</select>
</li>
<li>
<label id="fourth_title-lbl" class="hasTip">Fourth Select:</label>
<input id="fourth_title" class="text" type="text" size="3" value="200">
</li>
而且下面的mootools的javascript,工作正常。
document.id('first_switch').inject(document.id('first_switch').getParent().getNext(), 'bottom');
document.id('first_title').getParent().getPrevious().dispose();
document.id('second_switch').inject(document.id('second_switch').getParent().getNext(), 'bottom');
document.id('second_title').getParent().getPrevious().dispose();
不過我想,以減少我重複相同的代碼時數,因爲我有大約20或更多的類似的線,所以我期待到更短或使用。每個功能更簡化,但只是不能想辦法。
我想添加Selector旁邊的值框,以便它們在同一行上,而不是使用兩行。任何幫助高度讚賞。先謝謝你。
下面是一個鏈接,小提琴Example Code
非常感謝你,工作很棒。 – Baris
隨時接受答案。 –