如何在复选框上悬停时显示一些信息? [英] How to show some information while hover on checkbox?
本文介绍了如何在复选框上悬停时显示一些信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的复选框很少。当我将鼠标悬停在它们上面时,我想显示属于这些复选框的一些信息。我如何使用JS或JQuery做到这一点?
假设这是我的复选框
I have few checkboxes. I want to show some information belong to those checkboxes while I hover on them. How do I do it using JS or JQuery? Suppose this is my checkbox
<input type="checkbox" value="monday" checked="checked">
我想向用户显示Hello User或值'monday'或我数据库中的一些数据。如何?
I want to show a user "Hello User or the value 'monday' or some data from my Database. How?
推荐答案
只需在HTML对象中添加title属性即可。
Just add a "title" attribute to your HTML object.
<input title="Text to show" id="chk1" type="checkbox" value="monday" checked="checked" />
或在JavaScript中
Or in JavaScript
document.getElementById("chk1").setAttribute("title", "text to show");
或者在jQuery中
$('#chk1').attr('title', 'text to show');
这篇关于如何在复选框上悬停时显示一些信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文