我似乎無法弄清楚如何以{display: inline}
格式在下面的代碼中顯示兩個輸入,以便它們彼此相鄰而不是分開顯示。我看了其他帖子,並嘗試過jQuery,<style>
標籤,.setAttribute
等,以嘗試添加此CSS樣式。如何讓輸入內聯顯示?
我也嘗試在CSS中使用必需的display: inline
命令在HTML中創建一個類。我創建了這個功能來打開我的主頁上的一個按鈕被點擊。一切工作正常,我只是想兩個輸入(文本和按鈕)排列在一起。
任何想法我錯了?我是一名初學者。
var counter = 1;
var limit = 2;
var newdiv = document.createElement('div');
function addInput(divName){
if (counter == limit) {
(counter);
}
else {
nFilter.className = 'input';
newdiv.setAttribute("style", "display: inline;");
newdiv.innerHTML = "<br><input type='text' placeholder='Postal Code' name='myInputs[]'> " + " <input type='button' value='Lets Go!' onclick='url(file:///C:/Users/Joy/Documents/ZapList/HoldingPage.php)'>";
document.getElementById(divName).appendChild(newdiv).span;
counter++;
}
}
謝謝。是的 - 我刪除了顯示:內聯,它工作。這裏是我添加了我需要的內容:newdiv.setAttribute(「style」,「width:900px; white-space:nowrap;」); – JEA 2014-10-10 05:57:41