Q:

jQuery selecting attribute value of multiple elements with name attribute

I have a form that has multiple input, select, textarea elements. With jQuery, How can I get the name attribute values of each element? I have tried the following but its not working:
var names = $('[name]');
names.each(function(){
    console.log(names.attr('name'));
})

A:

You need to use this within the each() to refer to the element within the current iteration. Your current code is attempting to get the name of a set of elements which is logically incorrect. Try this:
var names = $('[name]');
names.each(function(){
    console.log($(this).attr('name'));
})

A:

You are still using names within your each function.  Try this:
var names = $('[name]');
names.each(function(index, name){
    console.log($(name).attr('name'));
})

