How do I Update the Content in Jquery UI Tooltip in Realtime?

后端 未结 6 1810
我在风中等你
我在风中等你 2020-12-31 01:58

I have an element that when hovered over, it displays the price of the item (in a game). I\'m using the jQuery UI tooltip to power the display of the information about each

6条回答
  •  别那么骄傲
    2020-12-31 02:44

    Why not do it this way?

    HTML:

     
     
     
    

    jQuery:

    // Every time a key is pressed (for the sake of example)
    $(function(){
        // Initialize tooltip
        $('.input-change').tooltip();
    
        // Every time a key is pressed (again, for the sake of example)
        $(".input-change").keyup(function(){
            // Get the actual value of the input that has changed (again, for the sake of example)
            var inputValue = $(this).val();
    
            // Get the id of the input that has changed
            var idInputChanged = "#" + $(this).attr('aria-describedby');
    
            // Go directly to the 
    inside the tooltip and change the text $(idInputChanged + ' div').html('Text changed in real time without closing tooltip!:
    ' + inputValue); }); })

    JSFiddle Example:

    http://jsfiddle.net/4MT5R/

提交回复
热议问题