0
我做了以下內容:使用InsertAfter移動元素,但只插入元素的父元素?
jQuery('.businessdirectory-category .wpbdp-rating-info').insertAfter('.businessdirectory-category .title');
要.title
後移動.wpbdp-rating-info
。但是,所以現在各.businessdirectory-category
已經3 01
我怎樣才能做到這一點,使每個.businessdirectory-category
徒有其自己的.wpbdp評級,資訊appended to its own
.title`有在第3頁.wpbdp-rating-info
?
編輯:
我改成了這樣:
jQuery('.wpbdp-listing-excerpt .wpbdp-rating-info').each(function() {
var $this = jQuery(this);
$this.insertAfter($this.closest('.wpbdp-listing-excerpt').find('.title'));
});
但也不能工作。
謝謝!但奇怪的是,它似乎沒有工作。也許你需要知道結構? (請參閱我的編輯)。也許是因爲WordPress不允許美元符號? – alexchenco
根據你的DOM結構,'.wpbdp-listing-excerpt'不存在。這個元素有兩個類名,'wpbdp-listing'和'excerpt'。儘管你可以將'.listing-details'傳遞給'.closest()',因爲它不像DOM樹那麼遠。 –
哦,它在那裏(只是截圖太小)。我得到這個:'未捕獲的SyntaxError:控制檯意外的輸入結束'雖然。 – alexchenco