There must be something else wrong in your page. The HTML and
selectors you gave work fine (see http://jquery.nodnod.net/cases/175).
Can you put a complete sample page online?

- ricardo

On Feb 25, 8:52 pm, RadicalBender <[email protected]> wrote:
> The rows are created on the fly, they aren't actually empty.  Here's a
> simplified version of what the table looks like:
>
> <table id="SetListTable" cellspacing="0">
> <tr><th>&nbsp;</th><th>Artist</th><th>Song</th></tr>
> <tr id="NoSongs" style="display:none;"><td colspan="4"
> class="last">There are no songs yet.</td></tr>
> <tr id="SongX"><td><a href="javascript:void(0)" onclick="DeleteSong
> ()"><img src="img/delete.png" /></a></td><td>Artist Name</td><td>Song
> Title</td></tr>
> <tr id="SongX"><td><a href="javascript:void(0)" onclick="DeleteSong
> ()"><img src="img/delete.png" /></a></td><td>Artist Name</td><td>Song
> Title</td></tr>
> <tr id="SongX"><td><a href="javascript:void(0)" onclick="DeleteSong
> ()"><img src="img/delete.png" /></a></td><td>Artist Name</td><td>Song
> Title</td></tr>
> </table>
>
> As you can see, there's a header row, then the NoSongs row, then all
> of the songs are looped over and displayed.
>
> When there are songs present, NoSongs is hidden. When the select menu
> is changed and no records are returned, NoSongs is made visible again.
>
> However, when I try to hide and then remove all of the song rows using
> $("#NoSongs ~ tr") to hide all rows after #NoSongs, it's not hiding or
> removing them.
>
> Hopefully I'm explaining this alright.
>
> --Ben
>
> On Feb 25, 5:03 pm, "Mauricio \(Maujor\) Samy Silva"
>
> <[email protected]> wrote:
> > Hi RadicalBender,
>
> > How about use the $('tr td:empty') selector to target the empties rows?
>
> > Not solve?
> > So,
> > need some more information to try figure out a solution.
> > Are there tbody, tfoot and thead in your table?
> > Where is located the  tr#NoSongs?
> > Would you please show a simplified sample of the table markup?
>
> > Maurício
>
> > -----Mensagem Original-----
> > De: "RadicalBender" <[email protected]>
> > Para: "jQuery (English)" <[email protected]>
> > Enviada em: quarta-feira, 25 de fevereiro de 2009 16:28
> > Assunto: [jQuery] ~ selector is not selecting siblings
>
> > > I have a table that has a list of songs - one for each row. I also
> > > have a select menu that populates the song table data from an AJAX
> > > query based on what was selected.
>
> > > The first row of the table is a row (#NoSongs) that just says "No
> > > songs were found." in case no records were returned. And I just hide
> > > and show that depending on the results.
>
> > > Whenever the select menu is changed, it calls a function where the
> > > logic is like this:
>
> > > function ChangeSongs() {
>
> > > $("#NoSongs ~ tr").fadeOut('slow',function() {
> > > $("#NoSongs ~ tr").remove();
> > > });
>
> > > // AJAX Query and a bunch of logic to create new table rows --
> > > Everything here on works fine.
>
> > > }
>
> > > The problem is that $("#NoSongs ~ tr") isn't finding any of its
> > > siblings. So, it just keeps adding new rows without deleting the old
> > > ones.  And $("#NoSongs ~ tr").size() returns 0 for some reason.
>
> > > I could try .siblings() but I only want the rows after #NoSongs
> > > (there's a table header row as well) and .siblings() returns all
> > > siblings forward and backward.
>
> > > I'm stumped. It should work even if #NoSongs is hidden from view,
> > > right? I'm really not comprehending why this isn't working.
>
> > > Any help would be appreciated. Sorry I can't show the actual code or
> > > site.

Reply via email to