I solved it by hiding the span with hide() rather than CSS. Although
I'd like to know why straight CSS breaks this while adding
display:none; via JavaScript works fine.
You mean this?
http://vidasp.net/jquery-example5.html
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,
Thank you all very much for replying. Mauricio's code worked for me :)
var el = $('#continer *:first').is('h2');
alert(el); // returns true if first child is H2, false otherwise
Again, thanks! :)
On Apr 7, 10:04 pm, Eric Garside gars...@gmail.com wrote:
I think I understand what you want. Try
This will return the tag name of a container's first child:
$('#container *')[0].tagName;
Hope it's useful!
Chuck Harmston
http://chuckharmston.com
On Tue, Apr 7, 2009 at 11:37 AM, bart b...@ivwd.nl wrote:
Hello all,
Let's say I'd have a div#content and I'd like to figure out what the
var $el = xx.is('h2'); //if it indeed matches a h2, returns true?
var el = $('#continer *:first').is('h2');
alert(el); // returns true if first child is H2, false otherwise.
Maurício
I think I understand what you want. Try this:
$('#content :first-child')[0].tagName.toLowerCase(); // Will return
a if it's an anchor, div for a div, img for an image tag, etc.
On Apr 7, 12:37 pm, Mauricio \(Maujor\) Samy Silva
css.mau...@gmail.com wrote:
var $el = xx.is('h2'); //if it
It's because tbody:first-child is already selecting the tr, so you're
effectively doing:
tbody tr tr (where the first tr is the first child of tbody)
Cheers,
David
Alex Wibowo wrote:
Hi all,
I have a code that counts the number of rows in a table...
the table looks like:
table
how does that explain the behaviour when there's thead then??
On Wed, Feb 25, 2009 at 7:47 PM, David Muir davidkm...@gmail.com wrote:
It's because tbody:first-child is already selecting the tr, so you're
effectively doing:
tbody tr tr (where the first tr is the first child of tbody)
sorry i should say
how does that explain the behaviour when there's no thead (because it
works when thead doesnt exist)
On Wed, Feb 25, 2009 at 8:06 PM, Alex Wibowo alexwib...@gmail.com wrote:
how does that explain the behaviour when there's thead then??
On Wed, Feb 25, 2009 at 7:47
tbody:first-child doesn't select the first child of the tbody it
says select the tbody that is the 'first-child' of it's parent.
So what you are actually wanting to say is:
$(#myTable tbody tr:first-child)
Which is select the tr that is the first child of tbody
Oops. Got tripped up by this last week too...
David
Karl Rudd wrote:
tbody:first-child doesn't select the first child of the tbody it
says select the tbody that is the 'first-child' of it's parent.
So what you are actually wanting to say is:
$(#myTable tbody tr:first-child)
Which is select
Hi Karl.. thanks for the reply...
what i actually wanted is to select the first tbody thats why i
specified tbody:first-child there
since a table can have multiple tbody... i want to select the first tbody.
What I didnt understand is about the thead..
the following works
Because tbody is no longer the first child.
What you want is tbody:first which will grab the first tbody.
David
Alex Wibowo wrote:
Hi Karl.. thanks for the reply...
what i actually wanted is to select the first tbody thats why
i specified tbody:first-child there
since a table
Assunto: [jQuery] Re: tbody:first-child thead
Hi Karl.. thanks for the reply...
what i actually wanted is to select the first tbody thats why i
specified tbody:first-child there
since a table can have multiple tbody... i want to select the first tbody.
What I didnt
: [jQuery] Re: tbody:first-child thead
Hi Alex,
1-) Doesn't work because * E F:first-child * pseudo-class selector matches
the F element that is the first child of the E element ONLY if there isn't
another element BEFORE the E element within the parent E. See specs at:
http://www.w3.org/TR
...
instead of: ...BEFORE the E element...
-Mensagem Original-
*De:* Mauricio (Maujor) Samy Silva css.mau...@gmail.com
*Para:* jquery-en@googlegroups.com
*Enviada em:* quarta-feira, 25 de fevereiro de 2009 09:24
*Assunto:* Re: [jQuery] Re: tbody:first-child thead
Hi Alex,
1-) Doesn't
@googlegroups.com
Enviada em: quarta-feira, 25 de fevereiro de 2009 09:43
Assunto: [jQuery] Re: tbody:first-child thead
ahhh
ok ... now i get it. sorry for wasting your time, guys...
i thought its E F:first-child reads the first child of E of type F... i
didn't know that it has
Tables have native properties which are much faster to access:
$('#myTable')[0].rows.length //number of rows
$('#myTable')[0].tBodies[0].rows.length //number of rows in the first
tbody
cheers,
- ricardo
On Feb 25, 5:25 am, Alex Wibowo alexwib...@gmail.com wrote:
Hi all,
I have a code that
Hi Ricardo
Thats great... thx a lot!
On Thu, Feb 26, 2009 at 5:06 AM, ricardobeat ricardob...@gmail.com wrote:
Tables have native properties which are much faster to access:
$('#myTable')[0].rows.length //number of rows
$('#myTable')[0].tBodies[0].rows.length //number of rows in the first
Ok, thank. I understand this. What I am asking however is how I can
accomplish what I am after? Any ideas? I would like for this div and
the list inside of it to slide down / tween down into position
together.
On Jan 23, 9:52 am, donb falconwatc...@comcast.net wrote:
The example doesn't
Anyone? Am a barking up the wrong tree?
On Jan 12, 10:48 am, Wacko Jacko jackson.be...@gmail.com wrote:
Hi donb,
It sounds like you know much more than I do. I am still quite new to
jQuery. Can you point me in the right direction to have these elements
slide in (down)?
Thanks in advance
The example doesn't 'slide' it has a fixed top position. The height
of the container increases from zero to some value, gradually
revealing the contents - much as if you are opening a sliding door.
On Jan 22, 6:05 pm, Wacko Jacko jackson.be...@gmail.com wrote:
Anyone? Am a barking up the wrong
Hi donb,
It sounds like you know much more than I do. I am still quite new to
jQuery. Can you point me in the right direction to have these elements
slide in (down)?
Thanks in advance for your help.
Jackson
On Jan 8, 2:01 pm, donb falconwatc...@comcast.net wrote:
Ddoesn't the animation
Ddoesn't the animation actually consist of an expanding div - meaning,
the contents (and the outermost div) are fixed in position? Nothing
is actually 'sliding down'
On Jan 7, 8:58 pm, Wacko Jacko jackson.be...@gmail.com wrote:
Hi All,
Quite new to jQuery so would very much appreciate your
You can do:
$('#test').after('liHello/li');
or:
$('#test').parent().append('liHello/li');
Rik
2008/11/7 jfk [EMAIL PROTECTED]:
Ok, this probably just needs someone to slap me towards a tutorial,
however I couldn't seem to find one!
I'm trying to use jquery to add a child to part of an
var $col = $('#row1 td') will give you a collection of all td under
row1, then you can filter by first, last, or even use ordianal positon
like $col[0] etc.
On Nov 5, 11:59 am, Jared_T [EMAIL PROTECTED] wrote:
I'm trying to access a td text value, as shown in the javascript
below. The easiet
On Wed, Sep 17, 2008 at 11:29 PM, Karl Swedberg [EMAIL PROTECTED]wrote:
Hi kcharles,
you need to concatenate the variable, n, with the rest of the selector
expression. Otherwise, it's treated as the string, n. Try this:
$(#filterTable tbody tr td:nth-child( + n + )).each(function(){
Also,
You rock!
That was it.
-Kevin
Do people really put td elements in a thead? Figured they would
just use th. Hadn't considered tfoot though. Good point.
--Karl
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Sep 18, 2008, at 5:44 AM, Richard D. Worth wrote:
On Wed, Sep 17, 2008 at 11:29 PM,
You're not really referencing the 'n' variable you just defined, as
you're passing a string.
var n = 2;
$(#filterTable tbody tr td:nth-child(+n+)).each(function(){
On Sep 17, 2:24 pm, kcharles [EMAIL PROTECTED] wrote:
I switch between var n = 2; nth-child(n) and nth-child(2) and get
Hi kcharles,
you need to concatenate the variable, n, with the rest of the selector
expression. Otherwise, it's treated as the string, n. Try this:
$(#filterTable tbody tr td:nth-child( + n + )).each(function(){
Also, you probably don't need either the tbody or tr part in there
since,
On Aug 23, 2008, at 11:11 PM, Dave Methvin wrote:
In contrast, :nth-child(even) selects the even children of the
element(s) in the jQuery object.
Just to clarify, :nth-child(even) selects all elements in the jQuery
object that are the even children of their parent.
For example,
No, they're definitely not equivalent in the general case.
The :even and :odd selectors apply to the even/odd elements in the
jQuery object. Depending on what has come earlier in the selector,
those elements may not even be related in any way.
In contrast, :nth-child(even) selects the even
On Apr 28, 2008, at 11:50 AM, wesbird wrote:
Hi,
I tried to select all td in the same row from a td, so I tried,
$(id).parent( td)
it does not work. How I can do it?
Hi there,
you can do it this way:
$(id).parent().children()
assume that id is a variable for the beginning td?
i jumped the gun a little, ui.selectable did the trick.
Thanks
- Original Message
From: [EMAIL PROTECTED] [EMAIL PROTECTED]
To: jQuery (English) jquery-en@googlegroups.com
Sent: Friday, April 25, 2008 4:39:34 AM
Subject: [jQuery] Re: jQuery Child Toggle Problems
Hi, Shaun
It's hard
Hi, Shaun
It's hard to know what you're getting at without an example?
The toggle event targets an element, hopefully the one you specified
when you called it ;) You can call it by class (thus, a set of
elements) and/or by the variety of selector options described in the
api docs
Thanks Jason :-)
How would I handle that if the #elHombre object is inside the form?
Cheers,
Dug
On Mar 27, 12:21 pm, Jason Huck [EMAIL PROTECTED] wrote:
Try this:
$('#elHombre').next('form').children('input select textarea')
[0].focus();
- jason
On Mar 27, 6:32 am, DugFalby [EMAIL
$('form:has(#elHombre)').children('input, select, textarea')[0].focus();
- Richard
On Mon, Mar 31, 2008 at 6:12 AM, dug [EMAIL PROTECTED] wrote:
Thanks Jason :-)
How would I handle that if the #elHombre object is inside the form?
Cheers,
Dug
On Mar 27, 12:21 pm, Jason Huck [EMAIL
On second thought, you'll want to use .find, instead of .children, as the
elements could likely be within fieldsets and/or divs:
$('form:has(#elHombre)').find('input, select, textarea')[0].focus();
Also, here's another way to get the form from the #elHombre:
Try this:
$('#elHombre').next('form').children('input select textarea')
[0].focus();
- jason
On Mar 27, 6:32 am, Dug Falby [EMAIL PROTECTED] wrote:
Hi guys,
I've got:
$('#elHombre').focus();
Which sets focus to a legend at the top of a form.
I'd like to do:
Hi Tomek,
It works fine for me. How are you testing this? If you have Firefox
with Firebug, inspect the last-child element after adding the class.
When I did so, I saw this:
div class=info green lastbar /div
(I had added bar to the HTML for the sake of my test.)
--Karl
_
Thanks everyone!
This is what I ended up using:
var index = $(this).parent().children(th).index(this) + 1;
/N
On Nov 26, 6:58 pm, Glen Lipka [EMAIL PROTECTED] wrote:
Getting the row is easier. :) There is a rowIndex
attribute.http://commadot.com/jquery/rowindex.php
Nuts, I am too late.
You could dynamically add a psuedo attribute like col with an each
function after the page loads.
Other than than, I would experiment with colgroup and see if it fires which
col you are in.
Sorry, no time for a demo. :( Hope this helps a little.
Glen
On Nov 26, 2007 7:35 AM, badtant [EMAIL
On 11/26/07, badtant [EMAIL PROTECTED] wrote:
When the user hovers the th-element I have a function. I want that
function to return which of the columns that has been hovered.
Something like this?
td class=col_a onMouseOver=alert(this.className);aaa/td
Adding a psuedo attribute like col with an each function would work.
I was hoping there would be some smart jquery-function for this.
Keep suggesting =)
On Nov 26, 4:46 pm, Glen Lipka [EMAIL PROTECTED] wrote:
You could dynamically add a psuedo attribute like col with an each
function after the
*Untested*
Something similar to:
var index = $(this).parent().find(' td').index(this);
-js
On 11/26/07, badtant [EMAIL PROTECTED] wrote:
Adding a psuedo attribute like col with an each function would work.
I was hoping there would be some smart jquery-function for this.
Keep suggesting
Getting the row is easier. :) There is a rowIndex attribute.
http://commadot.com/jquery/rowindex.php
Nuts, I am too late. Question answered. I whipped up a demo anyway.
http://commadot.com/jquery/colIndex.php
Fun question.
Glen
On Nov 26, 2007 8:10 AM, jonhobbs [EMAIL PROTECTED] wrote:
I
var myRows = $('table#id tr').click(function(){ alert('Row #' +
myRows.index(this) + ' clicked'); });
(index is 0-based, ie clicking on the 7th row returns 'Row #6 clicked'
in the example above.)
On Oct 10, 3:28 pm, RichUncleSkeleton [EMAIL PROTECTED] wrote:
Is it possible to detect the
For example, say I have a table with 10 rows. If I click on the 7th
row, is it possible to obtain the number 7 simply?
The tr element should have both a rowIndex and a sectionRowIndex; I've
never used them but they're documented.
You're binding to 'onfocus' when it should be 'focus':
$(#id1 [EMAIL PROTECTED]).bind(focus, foo);
On Sep 26, 8:35 am, Anjanesh [EMAIL PROTECTED] wrote:
Hi
I cant get this seem to work
$(#id1 [EMAIL PROTECTED]).bind(onfocus, foo);
Is there something wrong with the argument ?
Thanks
Also, your initial selector can be simplified to: $(#id1 :text)
--Erik
On 9/26/07, Remy Sharp [EMAIL PROTECTED] wrote:
You're binding to 'onfocus' when it should be 'focus':
$(#id1 [EMAIL PROTECTED]).bind(focus, foo);
On Sep 26, 8:35 am, Anjanesh [EMAIL PROTECTED] wrote:
Hi
I
But doesnt $(#id1 :text) select only the first textbox under #id1
element ?
I wanted to bind the focus function to all textboxes under id1.
But I found this plugin (http://www.texotela.co.uk/code/jquery/
focusfields/) to do what I wanted to do anyway.
Lwis wrote:
Hi,
short version: how do I find out whether my element is a child of
another element?
long version: I think I want to loop through all elements and check
each of them if it is the element I am searching for or not.
I think I want something similar to YUI
Lwis schrieb:
Hi,
short version: how do I find out whether my element is a child of
another element?
long version: I think I want to loop through all elements and check
each of them if it is the element I am searching for or not.
I think I want something similar to YUI
On Apr 6, 2007, at 8:53 AM, bmckenzie wrote:
$(#someParent).children().index(someElement) != -1 ;
Cool, Bruce!
you could also come at it from the other direction:
if ( $('#someChild').parent('someElement').length ) {
//do something
};
--Karl
_
Karl Swedberg
65 matches
Mail list logo