私はjsオブジェクトを持っています(それは実際には別のオブジェクト内のオブジェクトです):
item2 : {
itemTitle : "This is item 2",
itemContent : "To me, in France, a friend speaks from America. The energy that brings me his voice is born of dammed-up waters a thousand miles from where he sits. <p> The energy I burn up in listening to him is dispensed in the same instant by a lake formed in the River Yser..."
},
2つの項目(itemTitle
およびitemContent
)は、div内のそれぞれp
の要素に表示され、アコーディオン表示を構成します(タイトルが表示され、タイトルがクリックされるまでコンテンツは非表示になります)。
htmlタグ(この場合はp
タグ)を含むコンテンツを追加する場合を除いて、正常に機能します。最初の段落は非表示になり、2番目の段落は表示されますが、両方の段落がに設定されているp
要素に囲まれているため、両方を非表示にする必要があると思います。 display
none
だから私はブラウザ(Firefox最新)がp
要素を見てその2番目の段落をレンダリングしていると思っています。p
多分それを処理する2番目の要素を閉じたらと思いました。しかし、サイコロはありません。
私は過去2年間、Objective-cの作業を行ってきたので、css / js /htmlfooは少しずれています。非表示の要素内にある場合、ブラウザがこれを表示するのはなぜですか?
これが私がhtmlを生成する方法です:
//loop through the accordian properties and build out the html code for them
var i = 0;
for (thisItem in accordian.accordianItems) {
i++;
var thisItemData = accordian.accordianItems[thisItem];
var thisItemCode = "<div id=\"itemContainer\" itemID=\"item_" + i.toString() + "\">" + "<div id=\"itemTitle\"><p class=\"title\"><a href=\"javascript:void(0);\" class=\"titleBar\" itemID=\"item_" + i.toString() + "_titlebar\">" + thisItemData.itemTitle + "</a></p></div>" + "<div id=\"itemContent\"><p class=\"content\">" + thisItemData.itemContent + "</p></div>" + "</div>";
accordianCode += thisItemCode;
}
//push the code out to our container div
$("#accordianContainer").html(accordianCode);
私のcss:
#itemContainer {
margin: 0 0 5px 0;
}
.title {
margin: 0 0 2px 0;
height: 20px;
vertical-align: middle;
background-color: #39F;
color: #fff;
font-family: Arial, Geneva, sans-serif;
font-size: 14px;
font-weight: 900;
}
.title a {
color: #fff;
text-decoration: none;
}
.content {
margin: 0 0 0 5px;
color: #333;
font-family: "Times New Roman", Times, serif;
font-size: 12px;
font-weight: 200;
display: none;
}
どんな助けでもいただければ幸いです。
そして、はい、私はコード全体でアコーディオンのスペルを間違えました。そこで修正しましたが、ここでは修正しませんでした。:P
編集:brのpタグを切り替えると、問題は解決しました。だから私の新しい推測は、apがブロックアイテムである何かですか?brタグのスタイルを設定できると思いますが、pを付けたいのですが、何か提案はありますか?