我需要在35岁以后隐藏字符,当我将鼠标悬停在文本上时,显示全文会有所帮助
<a class="dep_buttons" href="#"> something text something text something text something text something text something text </a>
$('.dep_buttons').mouseover(function () {
if($(this).text().length > 30) {
$(this).stop().animate({height:"150px"},150);
}
})
$(".dep_buttons").mouseout(function(){
$(this).stop().animate({height:"40px"},150);
});
演示FIDDLE
jQuery的
$(function () {
$('.dep_buttons').each(function () {
var stringText = $(this).text().trim();
var substringText=stringText.substring(stringText,35);
var remainingText=stringText.substr(35);
$(this).html(substringText);
$('.dep_buttons').mouseover(function () {
$(this).find('a').show();
}).mouseout(function(){
$(this).find('a').hide();
});
$('<a style="display:none;">'+remainingText+' </a>').appendTo($(this));
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句