Monday, April 27, 2009

[jQuery] Re: div contains
  • -> select div but NOT li
  • Okay I'll try to explain better.


    Imagine an image, it's a rectangle.

    you can have a div with this image for background :

    like this :

    <div id="plan">
    ....
    </div>


    Then, with CSS, you can do this :

    #plan{
    background:url(my image url);
    width : image width;
    height: image height....
    }

    Well, my image is representing a map.

    over my map, I have little icons (like in google map : you have the
    map and spots)

    that's why I have something like this :


    <div id="plan"> <-- this is the map ID, with the map image for
    background
    <ul>
    <li>....</li>
    <li>....</li> <-- each li represents a spot. the spot is an
    image displayed at the spot position in the map -->
    <li>....</li>
    </ul>
    </div>


    I want to be able to click on the map (on the div #plan) but NOT on a
    li element.

    Is it more understandable ?

    Thank you very much


    On 27 avr, 13:55, Charlie <charlie...@gmail.com> wrote:
    > your question isn't very clear . If you are trying to select based on what is inside the div these should help:
    > $("div:contains("Some Text")).// do something
    > or
    > $("div:has(li[class=something])").// do somethinghttp://docs.jquery.com/Selectors
    > need to be more specific what you are trying to do. The way your question is written " $("plan"). //do something " would work
    > gostbuster wrote:Hi everyone, I would appreciate some help with what I wanna do. I explain my problem : I want to do a map-like: It means a div with background images, and some elements on it (a bit like in google map : you have the map in background, and stuff you can click over it. well i have this code : <div id="plan"> <ul> <li>....</li> <li>....</li> <li>....</li> </ul> </div> I would like to select #plan but NOT the li element inside. I tried some stuff but didn't succeed. I'm sure experts from here will solve this problem in less in a second. Thank you VERY MUCH in advance.

    No comments:

    Post a Comment