dancemc15 dancemc15 - 7 months ago 10
Javascript Question

How do I create change the color of the arrow on hover over?

I'm not sure if I wrote my HTML correctly. The script I have might not run because of that. I use paragraph to create space between the arrow and the text above (not shown).

<div class="littlebg">
<div class="text">
<hr>
Renowned Japanese author Haruki Murakami said he owns over <a href="http://www.nytimes.com/2011/10/23/magazine/the-fierce-imagination-of-haruki-murakami.html?pagewanted=5&ref=baseball&_r=0">10,000 records</a>. He often references music in his stories, particularly the genres classical, jazz and American pop. His first job was at a record store, and he once ran a jazz bar, called the Peter Cat, in Tokyo with his wife.
<a href="#begin2">
<p><div class="arrow"></div></p>
<a href="#begin2">
<p>
<div class="arrow"></div>
</p>
</a>

<script>
$("div.arrow").hover(function() {
$('this').css("border", '#4da6ff');
});
</script>

</div>

Answer

The reference is $(this) or this, not $('this').

Also, you're only considering mouseenter, you should write the second callback when the mouse leaves the element and restore the previous value.

Info: https://api.jquery.com/hover/