我试图摧毁除最后一个元素之外的所有元素 除了这行的Jquery代码:
$(".message_list .message_body:lt(:last-child)").hide();
这条线没有崩溃,我试过
:last child
:last-child
last()
:last
:last
没有什么能给我最后一个元素。 我如何选择比最后一个元素更少的元素? lt () 中写了什么?
我试图摧毁除最后一个元素之外的所有元素 除了这行的Jquery代码:
$(".message_list .message_body:lt(:last-child)").hide();
这条线没有崩溃,我试过
:last child
:last-child
last()
:last
:last
没有什么能给我最后一个元素。 我如何选择比最后一个元素更少的元素? lt () 中写了什么?
尝试此 :
$(".message_list .message_body:not(:last-child)").hide();
或取决于您的 HTML 结构, 您可能需要 < code>: last 。
$(".message_list .message_body:not(:last)").hide();
< a href=" "http://api.jquery.com/lt-selector/" rel="nofollow"\\\ code >:lt 将零基索引作为参数,而不是选择符。 如果您 必须 使用 :lt
:
var items = $( .message_list .message_body );
var lastItem = $( .message_list .message_body:last );
var index = items.index(lastItem);
$(".message_list .message_body:lt(" + index + ")").hide();
否则,请使用@rorys 回答。
$(".message_list .message_body:not(:last)").hide();
工作样本:"http://jsfiddle.net/WnCeH/2/" rel="nofollow">http://jsfiddle.net/WnCeH/2/
这里的样本可以帮助您从概念上找到解决问题的方法: http://jsfiddle.net/T5ZVE/
The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...
I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="...
I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.
I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...
Ok, I m stumped. Basically, this script works fine in FF, but not in IE (6,7 or 8) - in which it returns an "Object doesn t support this property or method" error. Any ideas?: function ...
What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...