對jQuery有點麻煩,請大家幫忙。點擊獲取列表p的內容並顯示在div中
我需要抓住P類的內容=「區域降序類=當」字幕被點擊,並在類=「臺階區域上顯示它
HTML:
<ul id="main-areas" class="group">
<li>
<div class="build-area">
<span class="caption bg">Planning</span>
</div>
<p class="area-desc">1Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a accumsan dolor. Curabitur rutrum augue nec eros blandit egestas. Aliquam lobortis posuere facilisis. Integer rutrum ullamcorper erat ac tempor. Nulla nec sapien nibh, non consequat dui.</p>
</li>
<li>
<div class="build-area">
<span class="caption bg">Arcitecture</span>
</div>
<p class="area-desc">2Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a accumsan dolor. Curabitur rutrum augue nec eros blandit egestas. Aliquam lobortis posuere facilisis. Integer rutrum ullamcorper erat ac tempor. Nulla nec sapien nibh, non consequat dui.</p>
</li>
<li>
<div class="build-area">
<span class="caption bg">Interior Design</span>
</div>
<p class="area-desc">3Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a accumsan dolor. Curabitur rutrum augue nec eros blandit egestas. Aliquam lobortis posuere facilisis. Integer rutrum ullamcorper erat ac tempor. Nulla nec sapien nibh, non consequat dui.</p>
</li>
<li>
<div class="build-area">
<span class="caption bg">Construction</span>
</div>
<p class="area-desc">4Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a accumsan dolor. Curabitur rutrum augue nec eros blandit egestas. Aliquam lobortis posuere facilisis. Integer rutrum ullamcorper erat ac tempor. Nulla nec sapien nibh, non consequat dui.</p>
</li>
</ul>
<div class="step-area bg">
</div>
jQuery的:
$('span.caption').click(function() {
var step = $('p.area-desc').html();
$('.step-area').html("<p>" + step + "</p>");
});
目前所有的代碼所做的是第一p標記的抓取內容並將其顯示在所希望的div
。我需要的是在每次點擊時在.step區域顯示每個描述的方法。
TA。在頁面加載時顯示第一個描述的最佳方式是什麼? – Rob
在頁面加載時添加了一些操作。看到上面的更新。 – techfoobar
再次歡呼。我對設置描述顯示有點不安:在我的樣式表中沒有,如果js被禁用,描述將不會顯示,你能建議一些東西來解決這個問題,或者是另一個帖子? – Rob