1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > html提示框title更改 设置title提示框的样式

html提示框title更改 设置title提示框的样式

时间:2021-01-06 19:20:13

相关推荐

html提示框title更改 设置title提示框的样式

默认的title不能设置样式,通过js和css实现title的功能

css样式:

/*修改提示框*/

#mytitle {

position: absolute;

color: #ffffff;

max-width: 160px;

font-size: 14px;

padding: 4px;

background: rgba(40, 40, 40, 0.8);

border: solid 1px #e9f7f6;

border-radius:5px;

}

html代码:

格式样式:

js代码:

$(function () {

var x = 10;

var y = 20;

var newtitle = '';

$('span.mytooltip').mouseover(function (e) {

newtitle = this.title;

this.title = '';

$('body').append('

' + newtitle + '');

$('#mytitle').css({

'left': (e.pageX + x + 'px'),

'top': (e.pageY + y - 80 + 'px')

}).show();

}).mouseout(function () {

this.title = newtitle;

$('#mytitle').remove();

}).mousemove(function (e) {

$('#mytitle').css({

'left': (e.pageX + x +10 + 'px'),

'top': (e.pageY + y - 60 + 'px')

}).show();

})

});

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。