我有以下代碼: -jQuery的 - 每個HTML()類值設置爲另一元件
HTML
<div id="nottingham-park-wrapper">
<div id="notts-main-court" class="icon-wrapper">
<span class="park-marker"></span>
</div>
<span id="notts-main-court-info" class="notts-info">
<h2 class="infobox-title">TITLE 1</h2>
<p class="infobox-desc">TEXT INFO 1</p>
</span>
<div id="notts-dodgeball" class="icon-wrapper">
<span class="park-marker"></span>
</div>
<span id="notts-dodgeball-info" class="notts-info">
<h2 class="infobox-title">TITLE 2</h2>
<p class="infobox-desc">TEXT INFO 2</p>
</span>
</div>
<hr>
<span class="mobile-notts-info"></span>
的jQuery
jQuery(".notts-info").each(function(index) {
var notts_info = jQuery(this).html();
jQuery(this).html('');
jQuery(".mobile-notts-info").html(notts_info);
});
基本上我想移動每個.notts-info
html裏面.mobile-notts-info
目前它只是移動每個循環中的最後一個值,我怎麼能得到所有的值? (在這個例子中只有2個,在實際版本中有很多,這就是爲什麼我想要使用每個而不是每個元素分開)
在此先感謝!
你只想要html還是整個''? –