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">
I want to show a user "Hello User or the value 'monday' or some data from my Database. How?
You can enter tooltip HTML into the label column of checkbox and radio data grids. The tabindex="0" attribute ensures that the user will be able to tab to the tooltip to activate it. The text that displays inside of the tooltip is entered inside of the data-wsf-tooltip attribute.
Just add a "title" attribute to your HTML object.
<input title="Text to show" id="chk1" type="checkbox" value="monday" checked="checked" />
Or in JavaScript
document.getElementById("chk1").setAttribute("title", "text to show");
Or in jQuery
$('#chk1').attr('title', 'text to show');
You can use attribute title and on step rendering add value of title from your database
input type='checkbox' title='tooltip 2'
You can use js plugin(you need to add value of requered text as attribute, see docs) http://onehackoranother.com/projects/jquery/tipsy/
Here is your answer:
<input type="checkbox" value="monday" checked="checked">
<div>informations</div>
and the css:
input+div{display:none;}
input:hover+div{display:inline;}
You have an example here
With an html structure like that:
<div class="checkboxContainer">
<input type="checkbox" class="checkboxes"> Checkbox 1
<div class="infoCheckbox">
<p>Info on checkbox 1</p>
</div>
</div>
<div class="checkboxContainer">
<input type="checkbox" class="checkboxes"> Checkbox 2
<div class="infoCheckbox">
<p>Info on checkbox 2</p>
</div>
</div>
<div class="checkboxContainer">
<input type="checkbox" class="checkboxes"> Checkbox 3
<div class="infoCheckbox">
<p>Info on checkbox 3</p>
</div>
</div>
You can easily show the text with "this" handler of jQuery which refers to the current element hovered:
$(".checkboxContainer").hover(
function() {
$(this).find(".infoCheckbox:first").show();
},
function() {
$(this).find(".infoCheckbox:first").hide();
}
);
Demo here: http://jsfiddle.net/pdRX2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With