Jquery 悬停并显示完整标题
Jquery hover and display back the full title
我目前创建了一个切换div,当div不悬停长标题时,其余字符会自动显示...
超过30个,到目前为止我已经成功创建了...
函数。
我需要当将鼠标悬停在div 上时,长标题将准确显示长标题全文。
JS小提琴
.JS
$('#popup_survey_whitebox_content').hide();
$("label#popup_survey_label_title").text(function (index, currentText) {
var newText = currentText.substr(0, 30);
if (currentText.length > 30) newText += "...";
return newText;
});
$("#popup_survey_whitebox").hover(function () {
$('#popup_survey_whitebox_content').stop().animate({
opacity: 1,
height: "toggle"
}, 500, function () {
// Animation complete.
}).css('position', 'relative');
$("#popup_survey_end_whitebox").click(function () {
$("#popup_survey_whitebox").remove();
});
});
例如:
全文长标题:测试测试测试测试测试123
长标题 : 测试测试测试测试测试...
当悬停时,它显示测试测试测试测试123
鼠标输出:测试测试再次测试...
您必须像这样缓存文本:
$('#popup_survey_whitebox_content').hide();
var orig = '', // create var to cache the original text
newText = ''; // create var to cache the new Text with "..."
$("label#popup_survey_label_title").text(function (index, currentText) {
orig = currentText;
newText = currentText.substr(0, 30);
if (currentText.length > 30) newText += "...";
return newText;
});
$("#popup_survey_whitebox").hover(function () {
$('#popup_survey_whitebox_content').stop().animate({
opacity: 1,
height: "toggle"
}, 500, function () {
$("label#popup_survey_label_title").text(orig); // Here put the original text.
}).css('position', 'relative');
}, function () {
$('#popup_survey_whitebox_content').stop().animate({
opacity: 1,
height: "toggle"
}, 500, function () {
$("label#popup_survey_label_title").text(newText); // Here put the new text with "..."
}).css('position', 'relative');
});
$("#popup_survey_end_whitebox").click(function () {
$("#popup_survey_whitebox").remove();
});
更新的小提琴。
语法是这样的:
$(elem).hover(fn, fn);
第一个fn
在悬停元素时执行,第二个fn
在鼠标离开元素时执行。 它只是MouseEnter,MouseLeave。
相关文章:
- Brightcove获取/显示HTML中的当前视频标题和描述
- 单元格的工具提示或标题不显示超过2000个字符
- 如何强制即时显示更改后的html标题
- 如何在标题上创建弹出框,当点击关闭按钮时,不使用jquery或php在网站中显示
- 为什么竞争不能在离子中显示(隐藏在标题下方)(离子竞争不能正常工作)
- 如何突出显示手动联系人的选定行和标题
- 当我悬停使用php连接到mysql的图像时显示标题
- 无法弄清楚为什么我的标题的其余部分不会显示
- 如何在 javascript 替换新图像/标题后正确显示 css 工具提示
- 如何使用 bootstrap3 和 php 突出显示标题中的活动页面
- 如何使收音机显示为标题?另外,我如何让收音机决定下一个盒子
- 向下滚动页面时在侧边栏中显示部分标题(也许使用 BS scrollspy?
- 类似facebook的按钮没有显示在fancybox标题中
- 如果我的网站在iframe中,我不希望标题显示在任何页面中
- 引导 - 当我尝试创建工具提示时,“数据原始标题=”显示为灰色
- 使网页的标题显示javascript变量
- 如何使输入字段标题显示输入字段中的文本
- FullCalendar & # 39; basicWeek& # 39;标题显示
- 在GWT中动态添加时,在SVG对象上使用标题显示工具提示是行不通的
- HTML表标题显示不正确