我想从CIDR块获取最大和最小IP - 我的当前代码工作正常,除了一些在最小数字上返回负数的IP.下面是我现有的代码和输出.
function long2ip (proper_address) {
// Converts an (IPv4) Internet network address into a string in Internet standard dotted format
//
// version: 1109.2015
// discuss at: http://phpjs.org/functions/long2ip
// + original by: Waldo Malqui Silva
// * example 1: long2ip( 3221234342 );
// * returns 1: '192.0.34.166'
var output = false;
if (!isNaN(proper_address) && (proper_address >= 0 || proper_address <= 4294967295)) {
output = Math.floor(proper_address / Math.pow(256, 3)) + '.' +
Math.floor((proper_address % Math.pow(256, 3)) / Math.pow(256, 2)) …Run Code Online (Sandbox Code Playgroud) 我正在使用jQuery对li标签列表进行排序,我目前的代码是:
var arr = [];
$("ul li").each(function() {
arr.push($(this));
});
arr.sort(cmpFunction);
$("ul").find("li").remove();
$.each(arr, function(index, item){
console.log(item.html());
});
Run Code Online (Sandbox Code Playgroud)
我在console.log中找到的是 - 我正在丢失包含li标签的外部(我希望保留html5数据属性)
是否还有.html()的另一个选项,它也会给我li标签的对象
我在这里提供了一个简单的例子:http://jsbin.com/esalas/5