Reputation: 12224
Note: This is CoffeeScript.
I've tried every iteration of this I can think of.
I want to loop through child elements and get the ids of the select
child of each:
$(this).closest(".control-group").nextUntil("#attribute_list").each (key, ele)->
console.log $(ele).children("select").attr("id")
I keep seeing "undefined" in the console log.
That element HAS a single child that is a select
. I just can't get it. No matter what I do.
Upvotes: 0
Views: 46
Reputation: 18093
Try:
$( @ ).closest ".control-group"
.nextUntil "#attribute_list"
.each ( key, ele ) ->
console.log( $( ele ).find( "select" ).attr( "id" ) )
note: this assumes the latest coffeescript compiler 1.7
Use this to upgrade:
sudo npm install -g coffee-script
Upvotes: 1
Reputation: 64657
I think you should be using $(this)
in this instance:
$(this).closest(".control-group").nextUntil("#attribute_list").each->
console.log $(this).children("select").attr("id")
Upvotes: 1