Works like a champ! Thank you again (mkmanning and karl) for all of
your help.
On Jun 19, 9:16 pm, bombaru bomb...@gmail.com wrote:
Thanks mkmanning!!! I'll give this a try tomorrow and let you know.
Looking at it though... I'm pretty confident it will do the trick.
It's amazing how much
One question with this approach... how would I implement this only on
groups that contain more than 10 LI's? Right now it's getting added
to every LI group. Groups with less than 10 LI's are also getting the
more link appended but there is obviously nothing to toggle.
Thanks again. This
You are a rock star! I can't thank you enough.
On Jun 20, 1:55 pm, mkmanning michaell...@gmail.com wrote:
A minor refactor then:
$('.main ul').each(function(){
var $this = $(this), lis = $this.find('li:gt(9)').hide();
if(lis.length0){
A minor refactor then:
$('.main ul').each(function(){
var $this = $(this), lis = $this.find('li:gt(9)').hide();
if(lis.length0){
$this.append($('li').text('More').click(function(){
lis.toggle();
$(this).text($(this).text() === 'More' ?
I'd probably use .slice().
Something like this should work:
$(document).ready(function() {
var $list = $('.main ul'),
$items = $list.find('li'),
$moreLink = $('a href=#more/a');
if ($items.length 10) {
$moreItems = $('ul/ul').append($items.slice(10)).hide();
Thanks Karl... I'm not familiar with slice() but will definitely read
up on it. The problem I'm having with this approach is that every LI
after the 10th one is being hidden.
Here's an example of what the HTML looks like without any JS applied
to it:
ul id=narrow-search
li class=main
Try this:
$('.main ul').each(function(){
var $this = $(this), lis = $this.append($('li').text('More').click
(function(){
lis.toggle();
$(this).text($(this).text() === 'More' ? 'Less' : 'More');
})).find('li:gt(9):not(:last)').hide();
});
Since you
And you can shorten it slightly:
$('.main ul').each(function(){
var lis = $(this).append($('li').text('More').click(function(){
lis.toggle();
$(this).text($(this).text() === 'More' ? 'Less' : 'More');
})).find('li:gt(9):not(:last)').hide();
});
I
Ah, I see. Helps to be able to see the HTML.
Let us know if mkmanning's approach doesn't do the trick.
--Karl
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Jun 19, 2009, at 5:56 PM, bombaru wrote:
Thanks Karl... I'm not familiar with slice() but will
Thanks mkmanning!!! I'll give this a try tomorrow and let you know.
Looking at it though... I'm pretty confident it will do the trick.
It's amazing how much more efficiently the original chunk of code can
be written and it still makes perfect sense (actually it's clearer).
On Jun 19, 7:36 pm,
10 matches
Mail list logo