views:

93

answers:

3
$('.testimonials blockquote p')
.prepend('<span class="quo ldquo">&ldquo;</span>')
.append('<span class="quo rdquo">&rdquo;</span>');

...prepends and appends TWICE. How do I prepend ldquo + whatever content inside the p + rdquo?

Thanks!

+2  A: 

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' });
alex
add the borders correctly to all 3 elements.
Nimbuz
+2  A: 

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.

T.J. Crowder
Ermm...yes included them in the markup too and forgot. sorry. :P
Nimbuz
@Nimbuz Please accept this answer if it gave you the solution :)
alex
sure, I couldn't accept an answer "within 3 mins" :)
Nimbuz
A: 
var $elem = $('.testimonials').find('p');
$elem.text($elem.text().replace(/(.*)/, "&ldquo;$1&rdquo;"));
jAndy