Selecting an element based on class and id in jquery - similar to an SQL query

Posted by Ankur on Stack Overflow See other posts from Stack Overflow or by Ankur
Published on 2010-03-23T09:07:23Z Indexed on 2010/03/23 10:53 UTC
Read the original article Hit count: 278

Filed under:
|

I want to select an element based on it's class and id, I have seen many similar questions on SO. Most of the users ask why would you ever want to do this - which is not very helpful, trust me, this is the simplest way of solving my UI problem, and it's a very unique and intereting UI related to making generic triple stores easily browsable.

At the moment the jQUery looks like this:

$(document).ready( function() {
    $(".predicates").hide();
    $(".objects").hide();
        $("#subject").click(
        function() { 
            $("#predId, .predicates").toggle(); // this line
            }
        );

        $("#predId").click(
        function() { 
            $("#objId, .objects").toggle();
            }
        );
});

The line I am really interested in is this

$("#predId, .predicates").toggle();

how do I get the select to ensure that both #predId and .predicates are true, at the moment it seems that only one or the other has to be true. Is there something like an && operator?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors