Question:
Output all elements count and print them to the page in the
following format :
Answer
var all = $('*');
console.log( all.length );
var elements = [];
for (var i = 0; i < all.length; i++){
if (!elements[$(all[i]).prop('tagName')])
elements[$(all[i]).prop('tagName')] = 1;
else
elements[$(all[i]).prop('tagName')]++;
};
console.log( all.length );
var elements = [];
for (var i = 0; i < all.length; i++){
if (!elements[$(all[i]).prop('tagName')])
elements[$(all[i]).prop('tagName')] = 1;
else
elements[$(all[i]).prop('tagName')]++;
};
console.log(elements);
allintext:"DOM JavaScript" "powered by blogger"
ReplyDeleteJavaScript is the language future. The new JavaScript Version (Ecmascript 6) has been relaeased.
JavaScript Online Training
Javascript Online Training
Wow. This really made my day. Thanks a lot!
ReplyDeleteJavascript Online Training Angularjs Training in CHennai