だから私は、次のHTMLを持っている: javascriptを作成したラベルが誤った位置に挿入
<div id="divForComponents">
<input type="button" value="+" onclick="addFilter('divForComponents')"/>
</div>
そして、私のスクリプトファイルに
:function addFilter(divId){
var div = document.getElementById(divId);
var label = document.createElement("label");
var text = document.createTextNode("Filter by:");
label.appendChild(text);
div.appendChild(label);
var filter = document.createElement("select");
filter.name = "selectName";
filter.options[0] = new Option("selection 1","value 1");
filter.options[1] = new Option("selection 2","value 2");
filter.options[2] = new Option("selection 3","value 3");
filter.options[3] = new Option("selection 4","value 4");
div.appendChild(filter);
var input = document.createElement("input");
input.type = "text";
input.name = "inputName";
div.appendChild(input);
}
今すぐ選択コンポーネントおよび入力フィールドが正しく追加されているが、ラベルはすでにそのdivにあるボタンの前に追加されます。私が好きなポジショニングを得ることが期待される:
代わりButton Label Select Input
私が手:
Label Button Select Input
それはここで何のためにカウントしている場合は、私が上でテストしてるブラウザはクロム、ではないはずです。
よろしく、 ボグダン
私はあなたのコード内のボタンが表示されません。 –
ボタンは既にdivにあります。 – Bogdan