jQuery li扩展了更多文本

时间:2014-01-17 22:35:42

标签: jquery jquery-animate custom-data-attribute

尝试让这些li元素单独展开,一次一个地被展开:http://jsfiddle.net/LU5dW/1/(使用data-text属性)

另一个http://jsfiddle.net/LU5dW/使用了跨度.menu_text类。无法在这里工作。

使用data-text的{​​{1}}属性的jQuery代码:

.append

$(document).ready(function() { $("#menu a").hover(function() { $(this).append($(this).children.eq(0).html("<span>" + $(this).children.eq(0).data('text') + "</span>")).css({width: 0}).stop(true, true).animate({width: "show"}, 700); }, function() { $(this).children(":last-child").stop(true, true).animate({width: "hide"}, 700).remove(); }); }); 类的jQuery代码,默认情况下为.menu_text

display: none

真的可以在这一个上使用另一双眼睛。谢谢你们:))

问题是我试图让每个项目在$(document).ready(function($) { $("#menu a").hover(function() { $(this).children(".menu_text").stop(true, true).animate({width: "show"}, 700); }, function() { $(this).children(".menu_text").stop(true, true).animate({width: "hide"}, 700); }); }); 上展开而不是在mouseenter上展开,但是对这两种方法都没有任何好运。 mouseleave方法正在抛出一个我无法捕捉的错误......

修改

现在使用data-text属性的另一种方法几乎可行,但它扩展了所有data-text元素,而不仅仅是其中的一个... arggg:http://jsfiddle.net/LU5dW/2/

li

1 个答案:

答案 0 :(得分:1)

我通过将float: leftclear: both添加到li样式来解决此问题。 还在overflow: hidden样式中添加了heighta,以便在li扩展时消除文本。

JSFiddle