我用JQ做了个表格中的title提示,代码如下:
//title jq提示
var sweetTitles = {
x: 10,
y: 20,
tipElements: "table tr td",
init: function() {
$(this.tipElements).mouseover(function(e) {
this.myTitle = this.title.replace(';', '<br/>');
this.myHref = this.href;
// this.myHref = (this.myHref.length > 200 ? this.myHref.toString().substring(0,200)+"..." : this.myHref);
this.title = "";
var tooltip = "";
if ((this.myTitle == "") || (this.myTitle == " ")) {
tooltip = "";
}
else {
tooltip = "<div id='tooltip'><p>提示框</p><p>" + this.myTitle + "</p></div>";
}
$('#tooltip').remove();
$('body').append(tooltip);
$('#tooltip')
.css({
"opacity": "0.9",
"top": (e.pageY + 20) + "px",
"left": (e.pageX + 10) + "px"
}).show('fast');
}).mouseout(function() {
this.title = this.myTitle;
$('#tooltip').remove();
// $('#tooltip').hide("fast");
}).mousemove(function(e) {
$('#tooltip')
.css({
"top": (e.pageY + 20) + "px",
"left": (e.pageX + 10) + "px"
});
});
}
};
$(function() {
sweetTitles.init();
});运行正常。问题在于表格是在asp.net AJAX 的UpdatePanel中定时更新的,一旦更新了就不行了。后来我加了如下代码:Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
function(sender, e) { $(function() {
sweetTitles.init();
});}
);加了这段代码后定时更新时还是正常的。但久了就变慢了出现页面假死现象。不知如何处理好。
另: this.myTitle = this.title.replace(';', '<br/>');这行代码在同一个单元格中title有多个“;”时,有时只替换了一个,有时
替换二个或全部。
//title jq提示
var sweetTitles = {
x: 10,
y: 20,
tipElements: "table tr td",
init: function() {
$(this.tipElements).mouseover(function(e) {
this.myTitle = this.title.replace(';', '<br/>');
this.myHref = this.href;
// this.myHref = (this.myHref.length > 200 ? this.myHref.toString().substring(0,200)+"..." : this.myHref);
this.title = "";
var tooltip = "";
if ((this.myTitle == "") || (this.myTitle == " ")) {
tooltip = "";
}
else {
tooltip = "<div id='tooltip'><p>提示框</p><p>" + this.myTitle + "</p></div>";
}
$('#tooltip').remove();
$('body').append(tooltip);
$('#tooltip')
.css({
"opacity": "0.9",
"top": (e.pageY + 20) + "px",
"left": (e.pageX + 10) + "px"
}).show('fast');
}).mouseout(function() {
this.title = this.myTitle;
$('#tooltip').remove();
// $('#tooltip').hide("fast");
}).mousemove(function(e) {
$('#tooltip')
.css({
"top": (e.pageY + 20) + "px",
"left": (e.pageX + 10) + "px"
});
});
}
};
$(function() {
sweetTitles.init();
});运行正常。问题在于表格是在asp.net AJAX 的UpdatePanel中定时更新的,一旦更新了就不行了。后来我加了如下代码:Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
function(sender, e) { $(function() {
sweetTitles.init();
});}
);加了这段代码后定时更新时还是正常的。但久了就变慢了出现页面假死现象。不知如何处理好。
另: this.myTitle = this.title.replace(';', '<br/>');这行代码在同一个单元格中title有多个“;”时,有时只替换了一个,有时
替换二个或全部。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货