2012-01-10 14 views

答えて

14

appendToは、あなたは以下のコードを使用することができ、要素のDOM

$('#foo, #bar').appendTo('#wrap'); 
0

はい、あなたは.after()を使用することができます。

$('#seven').after($('#foo, #bar')); 
1

の末尾に要素を移動します:

$('#wrap').append('<div id="foo"></div>') 
0

これは私が少しリード後、私はサイト全体で使用するには、もう少し一般的なものを必要な可能性が...スルーがベストです:TESTED

ブラウザ:クロム、Firefoxの、IE7、IE8、IE9

OBJECTIVE ... "その他"を下に移動する...サーバーサイドのコードでマークアップを変更する方法がありませんでした。

<select name="anyName" id="anyID" > 
    <option value="Other">Other</option> 
    <option value="Entry 1" >Entry 1</option> 
    <option value="Entry 2" >Entry 2</option> 
    <option value="Entry 3" >Entry 3</option> 
</select> 

<script type="text/javascript"> 
$(document).ready(function() { 
    $("select option").each(function() { 
     if($(this).text() === "Other" && $(this).parent("select").children("option:last-child").text() !== "Other") { 
      $(this).insertAfter($(this).parent("select").children("option:last-child")); 
     } 
    }); 
}); 
</script> 
関連する問題