I have a header element inside which is an anchor element is present. Below is the code:
<h3 class="header"><a href="http://www.google.com">Google</a></h3>
On click of the header element, some text appears below. To do this I have used jQuery. Below is the code:
$('.header').click(function() {
$header = $(this);
$anchor = $header.find("a");
$content = $header.next(); // Get next element
$content.slideToggle(100, function() {
$content.is(":visible") ? $anchor.css({'color': 'white'}) : $anchor.css({'color': '#1818bd'});
$content.is(":visible") ? $header.css({'background-color': 'black'}) : $header.css({'background-color': '#cccccc'});
});
});
On hover of the anchor element, the text changes to red color. Below is the code:
a:hover {color: red;}
Issue 1: On click of the anchor element, I don't want the text content below to appear. This should happen only on clicking the header element which is happening as expected.
Issue 2: After clicking on the header element the text content below it appears. Now if I hover over the anchor element, the text color doesn't change to red.
Below is the js fiddle link: https://jsfiddle.net/heisenberg_kl3/np5pmqLq/
Issue 2 is solved. Please provide a solution to issue 1.