I made a simple "website" that behaves like this:
- Clicked paragraph receives focus and changes background color to red.
- When user clicked one of the paragraphs (it received focus and changed color to red) and then user clicks other paragraph, the "old" paragraph looses focus and red color and passes it to the "new" clicked paragraph.
- When user clicked one of the paragraphs (it received focus and changed color to red) and then user clicks the background (projectsDiv) or any other element of the website the paragraph looses focus and red color.
I want the website to behave like this:
- Same as above
- Same as above
- When user clicked one of the paragraphs (it received focus and changed color to red) and then user clicks the background (projectsDiv) the paragraph looses focus and red color. Clicking any other element of the website doesn't affect focus of the paragraphs inside projectsDiv.
Here is a code:
<div class="container">
<div id="projectsDiv">
<p tabindex="0">P1</p>
<p tabindex="0">P2</p>
<p tabindex="0">P3</p>
</div>
<div id="tagsDiv">
<button id="Tag1" class="Tag">Tag1</button>
<button id="Tag2" class="Tag">Tag2</button>
<button id="Tag3" class="Tag">Tag3</button>
</div>
</div>
#projectsDiv p:focus {
background-color: red;
}
#projectsDiv {
border: 1px solid black;
}