I have a table-structure like bellow :
function highestPosInBlock(posId) {
// determine the highest number in the current block
console.log($("body").data("block")); // ...
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table data-block="1">
<tr>
<td data-position="1">1</td>
</tr>
<tr>
<td data-position="2">2</td>
</tr>
<tr>
<td data-position="3">3</td>
</tr>
</table>
<table data-block="2">
<tr>
<td data-position="1">1</td>
</tr>
<tr>
<td data-position="2">2</td>
</tr>
</table>
I want to retrieve the highest data-position
attribute of a given Block. My JS-Function so far looks like this:
function highestPosInBlock(posId) {
// determine the highest number in the current block
console.log($("body").data("block") // ...
}
and this is exactly where I'm stuck. The argument I pass is the given data-block. For instance, I'd call the function like this:
highestPosInBlock(1)
I want to retrieve 3
In case I'd call highestPosInBlock(2)
it shoudl return 2
Any idea how to do so? I have a complete blackout.
Another thing: I can't use the each-iterator in jQuery, since this shit has to work in IE 7, which doesn't support each()