를 사용하여 DOM에 동적으로로드 된 내용을 이동 - squarespace 6 .CSS내가 블로그 템플릿을 사용하고 JQuery와
마다에 나에게 .html 중에서 액세스 /과 제한된 액세스를 허용하지 않는 I 블로그 게시물을 만듭니다. 태그와 카테고리를 태그에 추가합니다.하지만 태그/카테고리는 블로그 게시물 하단에 있습니다. 나는 그들을 사이드 바에 옮기려고 노력하고있다.
$(document).ready(function(){
var $categories = $('div.categories').parent('article');
var $spanDate =('span.date').parent('article');
$categories.insertBefore($spanDate);
});
:
문제는 내가 페이지에 여러 블로그 게시물을 가지고있다, 나는 .tags
및 .category
클래스를 선택하기 위해 jQuery를 사용하여 다음과 같은 코드로 .date
전에 .sidebar
로 이동하기 위해 노력하고있어
는
문제는이 코드는 모든 블로그 게시물에서 태그/범주를 잡고 카테고리와 태그가 혼합지고, 그래서 모든 사이드에 적용입니다 (이 코드는 .categories에 대해서만 예이다).
부모 기사의 .tags
및 .category
을 선택하고 해당 코드로 이동하도록 코드를 가져 오려고합니다. 같은 부모의 sidebar
article
.
모든 블로그 게시물에 적용되기를 원하기 때문에 특정 ID를 사용할 수는 없지만 태그/카테고리는 해당 게시물 내에 있어야합니다. 내가 바로 당신을 이해 해요 경우
<blog> //Wrapper for the whole blog page
<content>
<article> //Each article is a blog entry
<section class="main"> //Contains the contents of the blog entry. This also has a dynamically generated ID,
//Blog Entry Content Goes Here
<footer>
<div class="meta"> //Contains the tags/categories I try to pull out of the DOM
<span class="tags"></span> //Contains the tags each wrapped in an `<a>`
<span class="categories"></span> //Contains the category tags
</div>
</footer>
</section>
<section class="sidebar"> //This is where I'm trying to place the tags/categories
<span class="date"></span> //I try to place the category before this in the jquery code above
<more spans....> // I try to place the tags appended onto the end of the sidebar (code not shown above).
</section>
</article>
<article></article> //More blog entries with same structure
<article></article> //More blog entries with same structure
<article></article> //More blog entries with same structure
</content>
</blog>
html의 샘플을 보는 것이 도움이 될 것입니다. –
@James는 html 구조체를 추가했습니다. 처음부터 그 부분을 넣었어야합니다 – pappley
jquery 호출에서 컨텍스트로 각 기사를 사용하고 기사를 사용하려고 했습니까? like (더미 코드) $ ('articles'). 각 (function (articelElem) {$ ('div.categories', articelElem) ....}) –