views:

36

answers:

1

Hi, I have the following HTML structure:

<div><a href="link1">blah</a></div>
<div><a href="link2">blah</a></div>
<div><a href="link3.swf">blah</a></div>
<div><a href="link4">blah</a></div>
<div><a href="link5.swf">blah</a></div>
<div><a href="link6.swf">blah</a></div>

Using jQuery I want to retrieve the links that contain the '.swf' extension and add a class to their parent div element. Here is my code, which is not working:

$('a[href:contains(".swf")]').parent().addClass=('filmtrigger')

Can you help me fix this? Thank you!

+4  A: 
$('a[href$="swf"]').parent().addClass('filmtrigger');

http://docs.jquery.com/Selectors

Aaron Saunders
Thanks! That did the trick! Now I want to remove the <a> link, but keeping the text content that is inside it. I need to strip only the <a> tag that wraps it. What do you recommend me to do?
Marcos Buarque
http://api.jquery.com/replaceWith/
Aaron Saunders
Thank you for that reference.
Marcos Buarque