<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Ajax Tooltip - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<h2>Ajax Tooltip</h2>
<p>The tooltip content can be loaded via AJAX.</p>
<div style="margin:20px 0;"></div> <a href="#" data-tip="This is the tooltip message1." class="easyui-tooltip" data-options="
content: function(){
//return $('<div style=\'padding:5px;background:#eee;color:#000\'>This is the tooltip message.</div>');
//return $('#toolbar');
//return $(this).data('tip').;
return $('<div style=\'padding:5px;background:#eee;color:#000\'></div>').html($(this).data('tip'));
},
showEvent: 'mouseenter',
position: 'bottom',
onShow: function(){
var t = $(this);
t.tooltip('tip').unbind().bind('mouseenter', function(){
t.tooltip('show');
}).bind('mouseleave', function(){
t.tooltip('hide');
});
}
">Hove me</a> to display tooltip content via AJAX. <div style="display:none">
<div id="toolbar" style="padding:5px;background:#eee;color:#000">This is the tooltip message.</div>
</div>
</body>
</html>

清洁的代码整理如下

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Tooltip - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
<script type="text/javascript">
//tip样式、显示\隐藏触发设置
function show(){
var t = $(this);
//tip样式设置小驼峰规则,marginLeft等同margin-left
t.tooltip('tip').css({
backgroundColor: '#fff000',
borderColor: '#ff0000',
boxShadow: '1px 1px 3px #292929',
marginLeft: '20px'
});
//tip显示\隐藏触发设置
t.tooltip('tip').unbind().bind('mouseenter', function(){
t.tooltip('show');
}).bind('mouseleave', function(){
t.tooltip('hide');
});
} //tip内容填充
function content(){
return $('<div></div>').append($(this).data('tip'));
}
</script>
<style type="text/css">
a {
line-height:80px;
} #container{
margin-left: 10px;
}
</style>
</head>
<body>
<div id="container">
<!--data-tip设置tip显示内容设置-->
<!--data-options中position: 'bottom'设置tip显示相对位置底部[bottom|top|left|right]-->
<!--data-options中showEvent: 'mouseenter'设置tip显示出发事件[mouseenter|click|none]-->
<a href="#" data-tip="This is the tooltip message." class="easyui-tooltip" data-options="content: content, showEvent: 'mouseenter', position: 'bottom', onShow: show">Hove me</a> to display tooltip content.<br />
<a href="#" data-tip="This is the tooltip message." class="easyui-tooltip" data-options="content: content, showEvent: 'mouseenter', position: 'bottom', onShow: show">Hove me</a> to display tooltip content.<br />
<a href="#" data-tip="This is the tooltip message." class="easyui-tooltip" data-options="content: content, showEvent: 'mouseenter', position: 'bottom', onShow: show">Hove me</a> to display tooltip content.<br />
<a href="#" data-tip="This is the tooltip message." class="easyui-tooltip" data-options="content: content, showEvent: 'mouseenter', position: 'bottom', onShow: show">Hove me</a> to display tooltip content.<br />
<a href="#" data-tip="This is the tooltip message." class="easyui-tooltip" data-options="content: content, showEvent: 'mouseenter', position: 'bottom', onShow: show">Hove me</a> to display tooltip content.<br />
</div>
</body>
</html>

再次优化后

index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Tooltip - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../tooltip.common.js"></script>
<style type="text/css">
a {
line-height:80px;
} #container {
margin-left: 10px;
}
</style>
</head>
<body>
<div id="container">
<!--data-tip设置tip显示内容-->
<!--data-options中position: 'bottom'设置tip显示相对位置底部[bottom|top|left|right]-->
<!--data-options中showEvent: 'mouseenter'设置tip显示出发事件[mouseenter|click|none]-->
<a href="#" data-tipcss=" backgroundColor: '#fff000',borderColor: '#ff0000',boxShadow: '1px 1px 3px #292929',marginLeft: '20px',width: '300px' " data-tipcontent="This is the tooltip message.This is the tooltip message." class="easyui-tooltip" data-options="content: tooltipcontent, showEvent: 'mouseenter', position: 'bottom', onShow: tooltipshow">Hove me</a> to display tooltip content.<br />
<a href="#" data-tipcss=" backgroundColor: '#fff000',borderColor: '#ff0000',boxShadow: '1px 1px 3px #292929',marginLeft: '20px',width: '300px' " data-tipcontent="This is the tooltip message." class="easyui-tooltip" data-options="content: tooltipcontent, showEvent: 'mouseenter', position: 'bottom', onShow: tooltipshow">Hove me</a> to display tooltip content.<br />
<a href="#" data-tipcss=" backgroundColor: '#fff000',borderColor: '#ff0000',boxShadow: '1px 1px 3px #292929',marginLeft: '20px',width: '300px' " data-tipcontent="This is the tooltip message." class="easyui-tooltip" data-options="content: tooltipcontent, showEvent: 'mouseenter', position: 'bottom', onShow: tooltipshow">Hove me</a> to display tooltip content.<br />
<a href="#" data-tipcss=" backgroundColor: '#fff000',borderColor: '#ff0000',boxShadow: '1px 1px 3px #292929',marginLeft: '20px',width: '300px' " data-tipcontent="This is the tooltip message." class="easyui-tooltip" data-options="content: tooltipcontent, showEvent: 'mouseenter', position: 'bottom', onShow: tooltipshow">Hove me</a> to display tooltip content.<br />
<a href="#" data-tipcss=" backgroundColor: '#fff000',borderColor: '#ff0000',boxShadow: '1px 1px 3px #292929',marginLeft: '20px',width: '300px' " data-tipcontent="This is the tooltip message." class="easyui-tooltip" data-options="content: tooltipcontent, showEvent: 'mouseenter', position: 'bottom', onShow: tooltipshow">Hove me</a> to display tooltip content.<br />
</div>
</body>
</html>

tooltip.common.js

//tip样式、显示\隐藏触发设置
function tooltipshow(){
var t = $(this);
//tip样式设置小驼峰规则,marginLeft等同margin-left
t.tooltip('tip').css(eval("({" + $(this).data('tipcss') + "})"));
//tip显示\隐藏触发设置
t.tooltip('tip').unbind().bind('mouseenter', function(){
t.tooltip('show');
}).bind('mouseleave', function(){
t.tooltip('hide');
});
} //tip内容填充
function tooltipcontent(){
return $('<div></div>').append($(this).data('tipcontent'));
}

easyui for jquery之tooltip的更多相关文章

  1. JQuery easyui (4)Tooltip (提示组件) 组件

    ps:先来一波美图 Tooltip的加载方式: 1,class加载 <a href="#" title="tooltip">hello word&l ...

  2. JS框架_(JQuery.js)Tooltip弹出式按钮插件

    百度云盘 传送门 密码:7eh5 弹出式按钮效果 <!DOCTYPE html> <html > <head> <meta charset="UTF ...

  3. easyui中jquery重复引用问题(tab内存泄露问题)

    今天认真测试了下easyui的一些兼容性问题,发现在ie9 ie10 首次加载的时候,会出现如下bug.如图所示: 认真看了下,我估计是脚本重复引用的问题,我用的iframe框架的模式.登陆系统后,桌 ...

  4. Easyui 修改jquery validatebox为英文校验提示为中文提示

    修改jquery validatebox为英文校验提示为中文提示 by:授客 QQ:1033553122 测试环境 jquery-easyui-1.5.3 问题描述: 如图,想把校验提示由英文改成中文 ...

  5. 解决 Jquery UI Tooltip 用在Select 的BUG

    今天遇到一个奇葩问题, 在chrome下一切正常的 页面,在IE 下Select无法选中! 是的  ,就是无法选中!!! 效果就是这样的.http://jsfiddle.net/slolife/dp4 ...

  6. 基于jQuery的Tooltip

    近来,要开发一个关务管理系统,为了增加系统美观度,自己开发了一个基于jQuery框的的小插件,与大家分享一下,希望大家能给我提出宝贵修改意见. 下面开发说明使用方法和内容: 一.引用jQuery框架, ...

  7. Jquery Easyui与Jquery Bootstrap的比较

    1.easyui是js框架 :bootstrap 是css框架 ,bootstrap = 样式库 + 一堆jQuery插件,顺便解释一句,如果你只需要bootstrap的样式,你完全不用引入jQuer ...

  8. Jquery Easyui与Jquery Bootstrap(Metronic Bootstrap)的简单比较

    1,通常来看WEB前端用 bootstrap 比较好,后台用EASYUI比较好.Easyui适合工厂企业的管理系统如ERP,CRM之类的,Bootstrap适用于多屏跨设备浏览. 简言之,一个适合上班 ...

  9. easyUI tree jQuery

    Tree 数据转换 所有节点都包含以下属性: id:节点id,这个很重要到加载远程服务器数据 which is important to load remote data text: 显示的节点文本 ...

随机推荐

  1. 【ABAP系列】SAP F4搜索帮助的高级版

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP F4搜索帮助的高级版   ...

  2. js导入外部文件

  3. python绘制五角星

    问题描述: python中运用turtle图形模块绘制五角星 问题分析: turtle绘制图形时,得知图形中重要点的坐标非常重要. 于是,绘制五角星问题转化成为一个数学问题,计算五个顶点坐标即可. 已 ...

  4. IDEA-包层级结构显示(三)

    IntelliJ IDEA包层级结构显示 如:A.B.C,在项目中希望以如下形式显示: A B C 效果: 再更换为A.B.C形式显示

  5. js 正则整理

    //严格验证身份证格式方法function idCardNo(value){ //验证身份证号方法 var area = { 11: "北京", 12: "天津" ...

  6. git比较重要但是又容易忘记的操作

    git rebase head~1   把多次commit合并成一次 git reset head  撤销已缓存的内容 git checkout . git stash      去除改动未提交的代码

  7. Weak Pair (dfs+树状数组)

    Weak Pair (dfs+树状数组) 题意 这个题目是要求:一颗树上,有n个节点,给出每个节点的权值.另外给出一个值k,问有多少对节点满足: \(power[u]*power[v]<=k\) ...

  8. React.memo

    介绍React.memo之前,先了解一下React.Component和React.PureComponent. React.Component React.Component是基于ES6 class ...

  9. 洛谷 - P4008 - 文本编辑器 - 无旋Treap

    https://www.luogu.org/problem/P4008 无旋Treap也可以维护序列. 千万要注意要先判断p节点存在才进行Show操作,不然输出一个'\0'(或者RecBin里面的东西 ...

  10. arcgis server地图服务切片(10.4.1)

    首先要发布地图服务,过程略 首先,熟悉arcgis server的人应该知道,最直接的切片方式操作方法是在“服务属性”中设置切片,但这种方式可操作性太差,很多设置无法实现,因此不推荐 下面正式开始,打 ...