I'm using Zepto.js, a lightweight jquery clone. But that framework doesn't use .data() in the same way as jquery. Now I need to use this code:
var position = new Array;
$('#ipadmenu > section').each(function() {
position.push($(this).data('order'));
});
But I have no idea how to make this work on my framework. How would I convert this to pure javascript? I have never really worked with arrays so i'm quite lost... also, might I have skipped something in the zepto doc (https://github.com/madrobby/zepto) that could help me with this? .get() for example?
Here is the HTML code. Basically I want to add all sections (the amount can change) into the array:
<nav id="ipadmenu">
<section data-order="0">
<a><p>text</p></a>
</section>
<section data-order="1">
<a><p>text</p></a>
</section>
</nav>
thank you for your help!
Based on my 30 second review of the zepto docs, it would look like this.
var position = new Array;
$('#ipadmenu > section').each(function() {
position.push($(this).data('order'));
});
the zepto docs you linked to say it supports all of the jquery methods in your snippet.
What about the data doesn't it handle? If it really doesn't handle data
the same it also supports attr
so you could say:
var position = new Array;
$('#ipadmenu > section').each(function() {
position.push($(this).attr('data-order'));
});