I am doing a website using asp.net C# and I would like to popup a small window with information as soon as mouse hover a particular word. I know that I have to use jquery but I don’t know exactly how to do it.
Any suggestions please?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are many plugins out there that will help you achieve what you are looking for. However it is also very possible to implement this functionality yourself. I wouldn’t be surprised either if some of the plugins you come across also use similar code.
The following is my attempt to demystify tooltip/popup plugin behaviour.
You could wrap the desired word in a
<span>element and give it a.hoverclass.Your jQuery (ver 1.7+) would look something like this :
I should add here that I am using a great and yet sometimes forgotten capability of jQuery called “chaining”. The
on()function actually returns the object that it was attached to. In this case$(".hover")– so if I want to call another function on that object I can just add it as another function at the end. Another example of this would be :$("#myElement").text("An error has occured!").css("color","#FF0000");That line of code would also at the text to
#myElementand also turn the colour red.With regard to your actual popup – I would suggest two things :