First you tag your links with a class
<div class="teacher-link" data-teacher="1" title="1" onmouseover="{link=1}">Alex Brown</div>
<div class="teacher-link" data-teacher="2" title="2" onmouseover="{link=2}">John Black</div>
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