this solution could be simplified a bit:

$('h3.example').each(function() {
  $('#deptFilter').append( '<option'> + $(this).html() + '</option>' );
});



--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Jan 3, 2010, at 6:53 AM, Paul Hutson wrote:

This will do what you want, first I assigned the elements via a
filter :

elements = $('h3').filter('.example');

Then I scrolled around the items found and output them to a span for
debugging.

elements.each(function() {
        $('#Output').html($('#Output').html() + "<br>" + $(this).html());
});

Here's the entire test code :

<html>
        <head>
                <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3/jquery.min.js"></script>
                <script type="text/javascript">
                        $(document).ready(function(){
                                elements = $('h3').filter('.example');
                                elements.each(function() {
                                        $('#Output').html($('#Output').html() + 
"<br>" + $(this).html
());
                                });

                        });
                </script>
        </head>
        <body>
                <h3 class="example">
                        LALALA
                </h3>
                <h3 class="notexample">
                        NOT example :)
                </h3>
                <h3 class="example">
                        Blub
                </h3>

                <br><br>
                <span id="Output">
                </span>
        </body>
</html>

On Jan 2, 8:25 pm, jason <jasona...@gmail.com> wrote:
Hey,

was wondering if anyone could help me with a basic JQ question. Ok so
I am trying to select each element that has a certain class on my
page, and then use what is inside of the <h3 class="example"> I am
selecting to populate a drop down select box with the id of
deptFilter. (with each result found inside of the H3, wrapped in
<option> tags.) I am having trouble understanding how I actually store
the variables found in each H3 with the class of "example".

Any help would be greatly appreciated.

Reply via email to