मैं जावास्क्रिप्ट का उपयोग कर अपने कोड में उल और ली तत्व बनाने की कोशिश कर रहा हूं। मैं निम्नलिखित है:जावास्क्रिप्ट में उल और ली तत्व बनाएं।
var test=document.createElement('section');
test.setAttribute('id','test');
var ul=document.createElement('ul');
document.body.appendChild(test);
test.appendChild(ul);
for (var i=0; i<array.length; i++){
var li=document.createElement('li');
ul.appendChild(li);
li.innerHTML=li.innerHTML + array[i];
}
मेरे सरणी php से json_encode का उपयोग कर
array[0]='aaa';
array[1]='bbb';
array[2]='ccc';
सीएसएस
section {
display: block;
width: 200px;
margin: 50px auto;
border: 3px solid red;
}
सब कुछ पार्स किया गया है को छोड़कर सूची शैली डॉट मेरी खंड टैग के बाहर है ठीक काम करता है।
यह क्रोम और आईई में इस तरह प्रदर्शित करता है लेकिन फ़ायरफ़ॉक्स ठीक काम करता है।
-------------
*| aaa |
*| bbb |
*| ccc |
-------------
मैं अपने अनुभाग टैग के अंदर अपना डॉट चाहता हूं। कोई विचार है? बहुत बहुत धन्यवाद।
<!DOCTYPE html>
<html>
<head>
<style>
ul#proList{list-style-position: inside}
li.item{list-style:none; padding:5px;}
</style>
</head>
<body>
<div id="renderList"></div>
</body>
<script>
(function(){
var ul = document.createElement('ul');
ul.setAttribute('id','proList');
var t, tt;
productList = ['Electronics Watch','House wear Items','Kids wear','Women Fashion'];
document.getElementById('renderList').appendChild(ul);
productList.forEach(renderProductList);
function renderProductList(element, index, arr) {
var li = document.createElement('li');
li.setAttribute('class','item');
ul.appendChild(li);
t = document.createTextNode(element);
li.innerHTML=li.innerHTML + element;
}
})();
</script>
</html>
काम कर jsfiddle उदाहरण here
'सूची-शैली-स्थिति: अंदर' का उपयोग करने का प्रयास किया? –
लॉल यह काम करता है। इतना ही आसान। अनुमान लगाओ क्रोम और आईई की जरूरत है। बहुत बहुत धन्यवाद। – Rouge
यह मेरे बिना काम करता है - http://jsfiddle.net/XepXZ/1 – Alnitak