Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
116 views
in Technique[技术] by (71.8m points)

javascript - what is the name of small win that appear by mouse over & how to create it

i want to know the name of small popup window that usually appear by mouse over an object and show some descriptions. for example in the following picture it has appear by mouse over on google search microphone Icon: i mean the windows that show by red arrow

and my next question is how to create this popup windows by java script.

question from:https://stackoverflow.com/questions/65644439/what-is-the-name-of-small-win-that-appear-by-mouse-over-how-to-create-it

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In general

You are looking for the HTML title attribute. This attribute is valid on any HTML element, as mentioned here: https://www.w3schools.com/tags/att_global_title.asp

In HTML

Thus you can add the title attribute to any HTML element. For example:

<a href="#" title="This is your tooltip content">Link</a>

I prepared a jsfiddle for you: https://jsfiddle.net/g2106c9e/

In Javascript

You can assign the title attribute dynamically to any element.

// Get a DOM element
var element = document.getElementById("some-element-id")

// Set this elements title attribute
element.setAttribute("title", "This is your tooltip content")

Here another working jsfiddle: https://jsfiddle.net/p5sLvd63/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...