dancemc15 dancemc15 - 1 year ago 64
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">
Renowned Japanese author Haruki Murakami said he owns over <a href="">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">
<div class="arrow"></div>

$("div.arrow").hover(function() {
$('this').css("border", '#4da6ff');


Answer Source

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.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download