I'm trying to re-sort the child elements of the tag input
by comparing
their category attribute to the category order in the Javascript
variable category_sort_order
. Then I need to remove divs whose category attribute
does not appear in category_sort_order
.
The expected result should be:
any
product1
product2
download
The code:
<div id=input>
<div category=download>download</div>
<div category=video>video1</div>
<div category=video>video2</div>
<div category=product>product1</div>
<div category=any>any</div>
<div category=product>product2</div>
</div>
<script type=text/javascript>
var category_sort_order = ['any', 'product', 'download'];
</script>
I really don't even know where to begin with this task but if you could please provide any assistance whatsoever I would be extremely grateful.