jQuery UI Tooltip with dynamic content

前端 未结 4 790
再見小時候
再見小時候 2021-01-22 13:20

I use jQuery UI Tooltip Widget and there is code:

  $(function() {$( document ).tooltip({  
    content: \'connecting\',
    content:function(callback) {
                


        
4条回答
  •  再見小時候
    2021-01-22 13:34

    First you tag your links with a class

    
    
    

    Then hook your tooltips on that class

    $(function() {$( ".teacher-link" ).tooltip({  
        content: 'connecting',
        content:function(callback) {
                var link = $(this).attr("data-teacher"); // here retrieve the id of the teacher 
                $.get('teacher.php?teacherid=' + link,{}, function(data) {
                callback(data);
            });
        },
    
      })});
    

    On non html5 page you can use another attribute like title:

       var link = $(this).attr("title"); // here retrieve the id of the teacher 
    

提交回复
热议问题