Using the data() function I add two values to some divs ($oRow points to divs)
$oRow.data("more", {moreValue: 750, moreIndex: 4});
Later on I’m trying to find the div (there is only one) which has a specific value for moreIndex
I’m doing it like so:
$oMore = $(".meter_battery_row").filter(function(){
return $.data(this, "more").moreIndex == 4;
});
But it doesn’t seem to work. After the above line I display window.alert($oMore) but it seems it doesn’t get to this line, so it runs in some kind of problem in the filter function.
Anyone got any ideas?
EDIT
.meter_battery_row are the classes of divs to which i attach the data values. ($oRow is of class .meter_battery_row)
You can add it data- attribute so you can retrieve it easier after and still use
$.fn.data():Here is a live example.