Simple function not working as expected
Hello, I wrote a function to check and see if a certain radio button was selected, and I'm passing an item from an array of HTML objects that I'll add to as I get more elements to check. Anyway, here's the code:
- (function ($) {
var active;
$.fn.checkRadioButtons = function (item) {
return this.each(function () {
return active = ($(this).attr('value') == item.value);
});
}
})(jQuery);
When I console.log the resulting item, it says, "[object Object]", and I'm expecting a value like true or false. I'm sure I'm doing something wrong here, or that I forgot something.
TIA,
Eugene "Eggers"
Edit: Here's how I'm calling it:
- var q4010active = $('[name="'+q4010.name+'"]').checkRadioButtons(q4010);
console.log("q4010 is "+q4010active);