Wednesday, September 30, 2009

[jQuery] Re: Hide row if empty

Assuming you can turn those id's into classes (where you have id="database")... you can do the following:

$(document).ready(function(){
    $('ul .database').each(function() {
        if ($(this).text() == "") {
            $(this).parent().hide();
        }
    });
});

On Wed, Sep 30, 2009 at 10:14 PM, Charlie Griefer <charlie.griefer@gmail.com> wrote:
If you're working with server side data like that, couldn't you just write a conditional in whatever language you're using (PHP, CF, ASP, etc) to not display the <li> if no data?

Also, do you really mean to re-use "database" as an ID for multiple elements?  ID's ought to be unique.


On Wed, Sep 30, 2009 at 9:43 PM, Wacko Jacko <jackson.beale@gmail.com> wrote:

Hi All,

If I had a list displaying data as follows:

<ul>
    <li id="item"><div>Label Here</div><div id="database">{content
here if available from database}</div></li>
    <li id="item"><div>Label Here</div><div id="database">{content
here if available from database}</div></li>
</ul>

Could I hide the whole <li id="item"></li> if their is nothing
available to show from the database in <div id="database"> ?

Thanks in advance for your help

Jack




--
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.



--
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.

No comments: