How to select the paragraph with only specific class
css, javascript, jquery, jquery-selectors, paragraph
Solution
You can use:
$('.p[class="p"]').css('color', 'red');
or:
$("p[class='p']").css('color', 'red');
Fiddle
Problem
Let say I have my HTML code look like this: ``` <p class="p">Paragraph</p> <p class="p p2">Paragraph 2</p> <p class="p p3">Paragraph 3</p> ``` If I use: `$('.p').css('color','red')`, this will apply red color to all paragraphs. How can I apply the style to paragraph that only has class `p` which is first paragraph in this case?