Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tooltips inside searchbox

Status
Not open for further replies.

czarj

Technical User
Apr 22, 2004
130
US
Using jquery i'm creating searchboxes that pull data from a MYSQL DB. How can I add tooltips into this:

Code:
        var impact_header_text = $("<div>Impact (EX: Panic)</div>");  <-- display header

        var impact_search_box = $('<input>')                 <--actual searchbox
            .attr('id', 'impact')
            .addClass('stat_table_search_field')
            .change(function (event) {
                current_pane.send_get_burt_data();
            });
        var impact_header = $("<th>")
            .append(impact_header_text,
                impact_search_box
        );

--- You must not fight too often with one enemy, or you will teach him all your tricks of war.
 
Set the title attribute with the text of the tool tip.
 
if I have a simple function like this:
Code:
$('[tooltip]').each(function() // Select all elements with the "tooltip" attribute
{
   $(this).qtip({ content: $(this).attr('tooltip') }); // Retrieve the tooltip attribute value from the current element
});

Can I just add an .attr into the search box? Such as:
Code:
        var bug_rel_search_box = $('<input>')
            .attr('id', 'bug_rel')
            .attr('title', tooltip="test")
            .addClass('stat_table_search_field')
            .change(function (event) {
                current_pane.send_get_burt_data();
            });


--- You must not fight too often with one enemy, or you will teach him all your tricks of war.
 
you are over complicating it.

in html the title attribute pops up on hover
example:
Code:
<a href="somepage.php" title="If you hover here you will see this pop up">Hover Here</a>

so if you want to add tooltips dynamically to a dom element in jQuery you just do this

Code:
$('#myDomElementID').attr('title','If you hover here you will see this pop up');

you can you fancy classes to pop up highly styled floating non-modal dialog boxes, but why unless there is a business required to do so, why bother?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top