Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show some information while hover on checkbox? [closed]

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?

like image 200
Ashish Kumar Sahoo Avatar asked Jan 16 '13 14:01

Ashish Kumar Sahoo


People also ask

How do I add a checkbox to tooltip?

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.


4 Answers

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');
like image 54
Louis Ricci Avatar answered Oct 22 '22 01:10

Louis Ricci


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/

like image 27
Anton Baksheiev Avatar answered Oct 22 '22 01:10

Anton Baksheiev


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

like image 12
Dan Ovidiu Boncut Avatar answered Oct 22 '22 01:10

Dan Ovidiu Boncut


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/

like image 3
Louis XIV Avatar answered Oct 22 '22 02:10

Louis XIV