Supposing I had the following HTML:
<html>
<head>
<title>My Test Page</title>
</head>
<body>
I liked the book <cite>Catcher In The Rye</cite>.
I also liked the book <cite>The Great Gatsby</cite>.
</body>
</html>
What I would like to know is if there is a way to select all the strings in between the <cite> and </cite> tags? What I am trying to do is add a css style to all text in between the cite tags. I know I could add a common class attribute to each one and select them using the class name, but there is a lot and I would hate to add it to each one. Does jQuery have a selector for cite tags?
$("cite")should get all instances.In jQuery, there are three main selectors:
A good way to think of it is “how would I go about defining a CSS definition to style one or more elements”? Generally that answer will give you a good selector to use in jQuery.
In your case, you could iterate over each CITE element and get the text/html like so: