문제

I want the "text complete" moved to the h3.title section .. When I use the following Jscript, the "text complete" is moved to the start of the div.caption. This element repeats several times on the page and needs to be specific to the closest match.

<div class="caption">...
<div class="date">...</div>
<h3 class="title">"text complete" should go here</h3>
<div class="taglist">...</div>
<div class="description"><h3>"text complete"</h3></div>

$('.description h3').each(function () {
$(this).prependTo($(this).closest('.caption'));

*where the Jscript says ".caption" I tried adding "h3.title" but it doesn't work.

도움이 되었습니까?

해결책

try this if i am not wrong in understanding your question

$('.description h3').each(function () {
$(this).prependTo($(this).closest('.caption').find(".title"));

this code will work if description is part of caption. your markup is not clear

and if it is not part of caption then try this

$('.description h3').each(function () {
    $(this).prependTo($(this).closest('.description').siblings(".title"));

다른 팁

Its extremely unclear as to what's needed here, but from your question, I think this might help. The code is very simple in this case

 $('.description').each(function () {
    $(this).siblings(".title").prepend($(this).find("h3").text());
});

Here's a fiddle : http://jsfiddle.net/XH8Sk/5/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top