attr() on radio return: undefined is not a function

I have this code

$.each($('input:checked', '#components-holder'), function(index, input){

And I got this error:

undefined is not a function

How can I iterate on all radio in my page and got value ?


The object sent to your callback as input is not a jQuery object, so you can't use jQuery methods. You need to convert it into a jQuery object to use jQuery methods:


Or use a native DOM property:


Or, you may wish to use map to get the appropriate values:

var values = $('#components-holder input:checked').map(function(index, input) {
    return input.value;

values is now an array containing all the relevant values.

Need Your Help

Does it make sense to use .apply( ) and pass the same instance as context?

javascript function call execution apply

I'm reading Javascript Web Applications, from O'Reilly. At various points in the book, the author uses something along the following:

Visualising a custom map with QGIS and D3.js is harmed by the projection

javascript json d3.js projection qgis

These are 4 polygons I have: in QGIS. I now wanted to use them with D3.js. I already tried out the things in QGIS generated shapefile malformed when converted to topojson by

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.