1

I'm trying to target the a tags that contain the html next » and add a class to that tag. I have tried using jQuery's contains but obviously it didn't work since I'm here.

$('a').contains('next »').addClass('next');

Which attribute do I need to use for this?

4

1 回答 1

3

You are looking for the :contains() selector (ref):

$('a:contains("next »")').addClass('next');
于 2012-05-20T05:48:07.300 回答