[jQuery] Using :first and :last on the first children of an element
I have some simple tables with multiple tr rows. The td cells within these rows have tables of their own. I'm trying to target the tr rows of the first (parent) tables, like so (excuse the spacing): HTML: table class=parent tr -- match with :first td table trtd/td/tr trtd/td/tr /table /td /tr tr -- match with :last td table -- ignore this child trtd/td/tr trtd/td/tr -- so do NOT match this with :last /table /td /tr /table jQuery: $('table.parent').each(function() { $(this).find('tr:first').dostuff(); $(this).find('tr:last').dostuff(); }); The :first tr works fine, since that's always the tr of the parent. But when I try to select the :last tr, it'll match the last tr of the nested table, and not the last tr of the parent table. How can I tell jQuery to only look at the trs that are in the parent table, and don't search any further in children tables? Thanks in advance for your help!
[jQuery] [autocomplete] matchContains in multiple words
http://docs.jquery.com/Plugins/Autocomplete Say I have the following entry in a data array: Quick brown fox Is it possible to return this entry when I search for e.g. qui fox? At this moment I can only get this result when searching for qui or fox, but not qui fox. I guess what I'm looking for is a way to split the input, and match each part against the data entries. Thanks in advance for your help.
[jQuery] Finding specific values within an element
Hi there. I just started to play around with jQuery. I'm hoping you could take a look at this and see if I'm at the right track, or that my approach is completely wrong. The idea is simple. I have a bunch of entries I want to display. When I click an entry, I'd like jQuery to retrieve the entry's ID and do something with this ID. What I did is the following. HTML div class=entrySomething herespan class=entryId12345/span/ div div class=entrySomething herespan class=entryId67890/span/ div The span is hidden, so the actual entry ID won't show up in the HTML. So now I can make a list with all my entries, each with a unique entryId value within the class. SCRIPT $(document).ready(function(){ $('.entry').click(function() { entryId = $(this).find('span.entryId').text(); alert(entryId); }); }); Whenever I click on an element with class entry, the function will look for the element entryId within that class, and gets the entryId using text(). Is this the right way to do this? Or is there an easier/better way? I was hoping for something like this: HTML div id=entry;12345something here/div div id=entry;67890something else/div SCRIPT that does: search for an element that starts with #entry; and then explode on ';' to find the entryId. Thanks in advance for any help or pointers!
[jQuery] Re: Finding specific values within an element
On Feb 8, 12:06 am, Alec sen...@gmail.com wrote: Is this the right way to do this? Or is there an easier/better way? I was hoping for something like this: HTML div id=entry;12345something here/div div id=entry;67890something else/div SCRIPT that does: search for an element that starts with #entry; and then explode on ';' to find the entryId. Posting my problems always gives me new ideas 5 minutes later :) I changed it to this: HTML div class=entry id=id-12345something here/div SCRIPT to get the ID number: $(this).attr('id').substr(3) (The id- part is for XHTML validation; I simply remove it with the substr() function.) I guess this is already much cleaner than the previous code.