function isLastChild(el) {
return el.parentNode.lastElementChild == el;
}
console.log(isLastChild(document.querySelectorAll('.tag')[0]));
var jsonData = {
"html": "<div id=\"user%%userid%%\"><span>You're ID: %%userid%%</span><img src=\"%%userimg%%\"></div>",
"data": [{"userid":"11", "userimg":"http://"},
{"userid":"22", "userimg":"http://"}
]};
var result = "";
jsonData.data.forEach(function(item) {
result += jsonData.html
.replace(/%%userid%%/g, item.userid)
.replace(/%%userimg%%/g, item.userimg)
});
console.log(result)
var simpleTemplate = (function() {
var replaceByObject = function(template, values) {
for (var key in values) {
if (values.hasOwnProperty(key)) {
var pattern = ['%%', key, '%%'].join(''),
keyRegexp = new RegExp(pattern, 'g');
template = template.replace(keyRegexp, values[key]);
}
}
return template;
};
return function(template, values) {
return replaceByObject(template, values);
};
})();
var jsonData = {
"html": "<div id=\"user%%userid%%\"><span>You're ID: %%userid%%</span><img src=\"%%userimg%%\"></div>",
"data": [{"userid":"11", "userimg":"http://"},
{"userid":"22", "userimg":"http://"}
]};
var result = "";
jsonData.data.forEach(function(item) {
result += simpleTemplate(jsonData.html, item);
});
console.log(result)
isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
if (isMobile.any()) {
alert('is mobile !');
}
function is_touch_device() {
return !!('ontouchstart' in window);
}
$(field).show().focus().click().hide();
value="{{ newPayment.shopId }}"
, ни ng-value="newPayment.shopId"
не сработало..Payment.reservePayment(function(response) {
$scope.newPayment = response;
});
("#item").click(function(){
$("#grid").load("js/template/template.html?" + (new Date).getTime());
});