I'm like most of novice web developers in most cases use jQuery, but more often I started to use clean js. So from here is my question: is it god practice to use clean js in jQuery scope, for example if i need to get elements class i can do this like:
jQuery('div#grid a').click(function(event){
event.preventDefault();
console.log(this.getAttribute('class'));
console.log(this.className);
console.log(jQuery(this).attr('class'));
});
But what is the best way?
The algorithm is as follows: Add the attributes contained in the attribute set X to the result set X+. Add the attributes to the result set X+ which can be functionally determined from the attributes already contained in the result set. Repeat step 2 until no more attributes can be added to the result set X+.
Some few examples of self-closing tags in HTML are <input/>, <hr/>, <br/>, <img/>, etc. Self-closing tags in HTML only have attributes and do not contain any content, and they also cannot have any children.
No. Because end tags are solely to define scope, the properties and attributes of the HTML element must be loaded when the tag is opened.
It's better to use the this.className
because it is the fastest among the three. Here's a demo which you can run and see the speed of execution: jquery attr(class) vs js.className
You can see after running the test that className
property is the fastest one.
Yes,use clean js in jQuery scope is good practise.Because this is native work with DOM and it works more faster.
Perfomance Test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With