質問

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