$('.testimonials blockquote p')
.prepend('<span class="quo ldquo">“</span>')
.append('<span class="quo rdquo">”</span>'开发者_如何转开发);
...prepends and appends TWICE. How do I prepend ldquo + whatever content inside the p + rdquo?
Thanks!
Your code doesn't prepend/append twice at this end. When I run it against this test HTML
<div class='testimonials'>
<blockquote><p>Testing</p></blockquote>
<blockquote><p>One</p></blockquote>
<blockquote><p>Two</p></blockquote>
<blockquote><p>Three</p></blockquote>
</div>
...I end up with each paragraph in quotes (just one pair, not two).
Perhaps your CSS is applying the quotes (look at the quo
and ldquo
/rdquot
CSS classes), and then of course you're also including them in your markup, and so ending up with two of each.
Maybe your selector matches 2 elements, or you have incorrectly nested p elements.
You could add a :first
, or try this to see how many it is matching
alert($('.testimonials blockquote p').length);
or see what they are matching like this
$('.testimonials blockquote p').css({ border: '1px solid red' });
精彩评论