If Else statements and the hover function

If Else statements and the hover function

Hello,
         I was wondering if it is possible to check if an object is being hovered on via an if else statement and
then do something if it is (if is on Hover true), or something if it is not (if is on Hover false).

Here is some psuedo-code... so checking if the user is hovering over the div with the id "text"
then the code will write the html paragraph telling what the user is doing in the paragraph with the id message

 if ("div#text").is(":hover"){
           
            function () {
       $("p#message").html("<p>The user is hovering over the text</p>")};
      };

      else
            function () {
       $("p#message").html("<p>The user is not hovering over the text</p>")};












Please help me out with this and i hope it is possible...

theoretically, if someone is just goes off of hover on one item (So they are not hovering anymore), they could be on hover of another object before the of Hover code is executed in the hover() function for the former object.
This would be Because the if / else that checks if you are on hover the second object is before the code that says what to do when the user is not hovering on the first object.

Thanks in advance and please contact me if you have any questions, comments, or solutions by replying or email me at theirf@gmail.com