Posts

Showing posts with the label js

Finding all elements with z-index inside a a page

var all = document.querySelectorAll('*'); for(var i = 0; i < all.length; i++) {if(all[i].style.zIndex > 0) {console.log(all[i].style.zIndex); console.log(all[i]);}}

שכפול אובייקטים ב- JavaScript באמצעות JSON פונקציות

Clone, Parse and Stringify JavaScript objects using JSON.parse and JSON.stringify without loosing functions in deep object: function localStringify(obj) {              return JSON.stringify(obj, function(key, val) { return (typeof val === 'function') ? val.toString() : val; }); } function localParse(str) {     return JSON.parse(str, function(key, val) { return (typeof val === 'string' && val.substring(0,8) === 'function') ? eval('(' + val + ')') : val; });         }   function cloneObject(obj) {     if (obj === null || typeof obj !== 'object') {                 return obj;    }             var temp = obj.constructor(); // give temp the original obj's constructor     for (var key in obj) {      ...