| 
									
										
										
										
											2018-10-04 14:47:55 +01:00
										 |  |  | --- | 
					
						
							|  |  |  | title: jQuery Hover Method | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # jQuery Hover Method
 | 
					
						
							|  |  |  | The jquery hover method is a combination of the ```mouseenter``` and ```mouseleave``` events.  | 
					
						
							|  |  |  | The syntax is this: | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | $(selector).hover(inFunction, outFunction); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | The first function, inFunction, will run when the ```mouseenter``` event occurs. | 
					
						
							|  |  |  | The second function is optional, but will run when the ```mouseleave``` event occurs.  | 
					
						
							|  |  |  | If only one function is specified, the other function will run for both the ```mouseenter``` and ```mouseleave``` events. | 
					
						
							| 
									
										
										
										
											2018-10-14 18:18:11 +02:00
										 |  |  | Below is a more specific example. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | $("p").hover(function(){ | 
					
						
							|  |  |  |     $(this).css("background-color", "yellow"); | 
					
						
							|  |  |  | }, function(){ | 
					
						
							|  |  |  |     $(this).css("background-color", "pink"); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2018-11-07 15:34:13 +00:00
										 |  |  | So this means that hover on paragraph will change its background color to yellow and the opposite will change back to pink. | 
					
						
							| 
									
										
										
										
											2018-10-04 14:47:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### More Information
 | 
					
						
							|  |  |  | More information can be found [here]. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [here]: https://www.w3schools.com/jquery/event_hover.asp |