+ 1
jQuery
What is jQuery really used for? And what is or are its advantages over native JS?
4 Antworten
+ 9
For handshorting JS writing essentially, and providing easier cross browers support handling mainly... it provide also a bind for such relative complex API as to handle AJAX ^^
With success, it have provided some extension as JQueryUI to handle layout effects...
+ 3
It makes you easier to code saving your time and making simplier some things.
For example you have 3 Paragraphs and you'd like to change bgcolor and font-style for each of them:
<p>One</p>
<p>Two</p>
<p>Three</p>
So you'll have code like this in JavaScript:
<script>
let ps = document.getElementsByTagName('p');
for (let i=0; i<ps.length; i++) {
ps[i].style.background = 'red';
ps[i].style.fontStyle = 'italic';
}
</script>
And like this - in jQuery:
<script>
$('p').css({'background':'red', 'font-style':'italic'});
</script>
And one more line is in <head> to import jQuery support to your page scripts:
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
+ 1
OK. Thanks, mate.
- 2
JavaScript query maybe