mouseover true if. true, if. element mouseover, DOM .
, , - CSS p.font2 p.font1:hover
, JavaScript , this onmouseover, IE Q4(this). , .
<html><head>
<style>
p.font1 {
color: blue;
white-space: nowrap;
display: inline-block;
}
p.font2 {
color: #2E2E2E;
white-space: nowrap;
display: inline-block;
}
</style>
<script>
function Q4(element)
{
element.className='font2';
}
</script>
</head>
<body>
<p class="font1" id="change4_1" onmouseover="Q4(this)"> Menu1</p>
<p class="font1" id="change4_2" onmouseover="Q4(this)"> Menu2</p>
<p class="font1" id="change4_3" onmouseover="Q4(this)"> Menu3</p>
</body>
</html>
Hide result. .
, onmouseover="this.className='font2';"
, JavaScript, jQuery, script ( CSS :hover ). , :
<html><head>
<style>
p.font1 {
color: blue;
white-space: nowrap;
display: inline-block;
}
p.font2 {
color:#2E2E2E;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js">
</script>
<script>
$( document ).ready(function() {
$( "p.font1" ).on({
"mouseover": function() {
console.log( "hovered!" );
var elem = $( this );
elem.addClass( "font2" );
},
"mouseout": function() {
console.log( "unhovered!" );
var elem = $( this );
elem.removeClass( "font2" );
}
});
});
</script>
</head>
<body>
<p class="font1" id="change4_1"> Menu1</p>
<p class="font1" id="change4_2"> Menu2</p>
<p class="font1" id="change4_3"> Menu3</p>
</body>
</html>
Hide result, jQuery $, , , p font1 mouseover mouseout. , , JavaScript (, ), , , . , p "font1" "font1 font2" . font2 css .
, , , .
source
share