tags:

views:

60

answers:

4

hi,

does the "find" method work in jQuery with classes selectors ?

For example:

var tagsDiv = $(".node-form .taxonomy-super-select-checkboxes").find("div.fieldset-wrapper");

doesn't work. But

var tagsDiv = $(".node-form .taxonomy-super-select-checkboxes").find("div#edit-taxonomy-tags-1-wrapper");

works. This is the html code:

...

<fieldset class=" collapsible">
   <legend class="collapse-processed">
       <a href="#">Tags
          <span class="form-required" title="This field is required.">*</span>
       </a>
  </legend>
  <div class="fieldset-wrapper">
     <div class="form-item" id="edit-taxonomy-tags-1-wrapper">
        <label for="edit-taxonomy-tags-1">Enter New Tags: </label>
     </div>
  </div>
</fieldset>

...

thanks

A: 

Long story short:

.find() does work with any valid selector type.

jAndy
A: 

The .find method supports all jQuery selectors, including class selectors.

You probably have a different problem.
Where is .taxonomy-super-select-checkboxes?

SLaks
A: 

I suppose the HTML You show is inside the .node-form .taxonomy-super-select-checkboxes whatever it is.

div.fieldset-wrapper and div#edit-taxonomy-tags-1-wrapper are two different divs in Your html, so if You expect the same output from both then one of them will not do what expected. But it doesn't mean that find is wrong.

You provided selectors for two different elements

naugtur
+1  A: 

The answer to your question is Yes. The Find method works with all valid selectors.

The set of elements returned by the selector $(".node-form .taxonomy-super-select-checkboxes") must contain one or more child elements that match "div#edit-taxonomy-tags-1-wrapper", but contain zero child elements that match "div.fieldset-wrapper".

Without seeing the full context of the document fragment you have posted, that’s all I can say.

Andy McCluggage