html reorder list aaccording
>>> a = [1, 2, 3]
>>> a[0], a[2] = a[2], a[0]
>>> a
[3, 2, 1]function sortMeBy(arg, sel, elem, order) {
var $selector = $(sel),
$element = $selector.children(elem);
$element.sort(function(a, b) {
var an = parseInt(a.getAttribute(arg)),
bn = parseInt(b.getAttribute(arg));
if (order == "asc") {
if (an > bn)
return 1;
if (an < bn)
return -1;
} else if (order == "desc") {
if (an < bn)
return 1;
if (an > bn)
return -1;
}
return 0;
});
$element.detach().appendTo($selector);
}
/* arg : The data-filter to parse for sorting. In our case it would be “data-category”
sel : This will be the parent selector that contains the data filter. In our case it is the class “search-results”
elem : This further narrows down the child elements within the parent selector, which is just a “li” in this case
order : This specifies the sort order. “asc” or “desc” would either be acceptable *\
Also in HTML:
- Adding and Deleting html Elements
- html table filter by all columns
- how to set background image for web page in html local image
- what does htmlentities do in php
- svg circle
- name a input submit html
- move cursor to end of line javascript
- ionic range
- how do i make a line in html
- download button html
- html email template
- how to import google font
- html video preload
- html add vertical space below
- html video repeating
- Html paragraph
- afjsi sein
- how can i make a quote element in html
- jquery replace innerhtml
- hidden input
- a href
- center text in a html file
- game engine
- how to hide error in laravel