Get width and height of an element
jQuery
var myImage = $('#myImage');
myImage.width(); // gets width of image
myImage.height(); // gets height of image
Javascript
var img = document.getElementById('myImage');
var imgwidth = img.style.width; // gets width of image
var imgheight = img.style.height; // gets height of image
Loop through some elements
jQuery
$('a').each(function(index, value){
console.log($(this).attr('href')); // loops through all 'a' elements, logging their 'href'
});
Javascript
var aelements = document.getElementsByTagName("a"); // runs a selector for all 'a' tags
var aelementsl = aelements.length; // gets the amount of 'a' tags
while(aelementsl--){
console.log(aelements[aelementsl].getAttribute('href')); // logs all the hrefs
}
Showing & hiding elements
jQuery
var myElement = $('#myElement');
myElement.show(); // shows the element with id 'myElement'
myElement.hide(); // hides the element with id 'myElement'
Javascript
var myElement = document.getElementById('myElement');
myElement.style.display = "block"; // shows the element with id 'myElement'
myElement.style.display = "none"; // hides the element with id 'myElement'