Home > Article > Web Front-end > In-depth knowledge of JavaScript
This time I will bring you in-depth JavaScript little knowledge points, Little knowledge points about using JavaScriptWhat are the precautions, the following are practical cases, Let’s take a look.
1. There are 4 methods to get elements on mainstream browsers:
getElementsByName getElementById getElementsByTagName getElementsByClassName There are 4 of them They are all attributes on the document object. They must be called through the document object.
However, getElementsByTagName and getElementsByClassName can also be called through the DOM object (element). They cannot be called. Call getElementById through DOM!!!
##2.var aA = document.getElementsByTagName('a'); aA looks like an array, but it is not. It is a collection of elements. 'length' and other attributes; but you cannot use sort() to sort!
3. Set transparency:
opacity:0.3; //兼容chrome和fffilter:alpha(opacity:30);//兼容低版本的IE
4. Calculate
Math.round(): Rounding;Math.abs(): Absolute value;
Math.ceil(): Rounding up Math.ceil(3.41) The result is 4, Math.ceil(-- 9.8) The result is -9;
Math.floor(): Round down Math.floor(-0.9) The result is -1;
In-depth basic application of JavaScript
The above is the detailed content of In-depth knowledge of JavaScript. For more information, please follow other related articles on the PHP Chinese website!