user603007
user603007

Reputation: 11794

jquery: how to hide second div?

i got a jquery question, how can I hide the first/second div, so now it shows Search, Search. I would like to have 'Search':

<tbody>
    <tr>
        <td class="ui-pg-button ui-corner-all" title="Reload Grid" id="refresh_jqgProducts">
            <div class="ui-pg-div">
                <span class="ui-icon ui-icon-refresh"></span>
            </div>
        </td>
        <td class="ui-pg-button ui-corner-all" title="Search">
            <div class="ui-pg-div">
                <span class="ui-icon ui-icon-search"></span>Search</div>
        </td>
        <td class="ui-pg-button ui-corner-all" title="Search">
            <div class="ui-pg-div">
                <span class="ui-icon ui-icon-search"></span>Search</div>
        </td>
    </tr>
</tbody>

i tried something like: $("td .ui-pg-div :nth-child(1)") to retrieve this but to no avail.

Upvotes: 0

Views: 4960

Answers (5)

user603007
user603007

Reputation: 11794

I found it with your help:

$("div.ui-pg-div:eq(1)").hide()

Thanks all!

Upvotes: 2

Roko C. Buljan
Roko C. Buljan

Reputation: 206209

$('td .ui-pg-button').gt(0).find('div').hide();

http://api.jquery.com/gt
http://api.jquery.com/eq

Upvotes: 2

Sender
Sender

Reputation: 6858

$('td:gt(1)').hide();​

see this demo

Upvotes: 0

JakeJ
JakeJ

Reputation: 1381

In your javascript, as you are working instantly in the element you will have to make sure you have Document.Ready in your scripts.

$(document).ready(){
    $('td[title="Search"]:first').remove();
}

I'm going to match any td with the title of 'Search' so that it will only ever hide the first occurence of the 'Search' item no matter the order.

I'm also removing the item, not just hiding it

Upvotes: 0

gabitzish
gabitzish

Reputation: 9691

$(".ui-pg-button[title='Search']").gt(0).find('div').hide();

Upvotes: 0

Related Questions