Undefined Variable In Array In Prototype
I have the following code:
Solution 1:
I think you're confusing the properties which pluck() works on with HTML attributes. It's anyway easier to add the pseudo class of checked as part of the initial selector, like:
$$('li.litemd input:checked').each(function(s) {
alert(s.next().innerHTML);
});
Solution 2:
Solution 3:
.pluck()
returns an array of values (whatever property name you passed in), so it's not filtering your results to the checked
ones, it's literally returning a [false, false, false]
array.
Instead I think you want this:
$$('li.litemd input').each(function(s) {
if(s.checked) alert(s.next().innerHTML)
});
You can give it a try here, note the addition of input
to the selector, since you're cheking on the property of the <input>
inside the <li>
, not on the <li>
itself.
Post a Comment for "Undefined Variable In Array In Prototype"