Jquery tips | SoloLearn: Learn to code for FREE!

+65

Jquery tips

hi 😄😄 What's the usefulest keywords in Jquery please ? 🤔🙉

10/26/2017 5:13:18 PM

Maxımee

34 Answers

New Answer

+7

ben alors finalement on se met au Jquery ? 😆 si tu veux qu'un code Jquery fonctionne, encadre le toujours de $(document).ready(function () { //ton code; }); et la quasi totalité du jquery sera le $("#tonID") ou $(".taClass") .ceQueTuVeuxFaire(); --> .attr .css .animate .hide .show .fadeIn .fadeOut .delay et plein d'autre. renseigne toi sur internet. et tu peux faire par exemple : $("body").hide(500).delay(1000).show(500); et ton body disparaîtra en 0.5s et 1s après il reapparaitra en 0.5s. tu peux aussi l'ecrire : $("body") .hide(500) .delay(1000) .show(500); en plusieurs lignes, c'est possible. $(maVariable) $("monTag") $(".maClass") $("#monID") https://code.sololearn.com/WQ1LXrV2Sf3u/?ref=app https://code.sololearn.com/W0pNLQ8bef6J/?ref=app https://code.sololearn.com/WC4Ncb88P3rB/?ref=app

+41

The two things I enjoy most about jQuery is that you can use $() to specify selectors (IDs/classes) instead of having to type out the drawn out stuff that vanilla JS uses to specify an element; that alone makes jQuery worthy imo. My other fav thing about jQuery is how it handles AJAX. Btw, another cool thing about jQuery is that you can chain things together. EXAMPLE: $(selector).hide().show() ^Makes it really easy to perform multiple functions on a particular element without having to do it individual for the same element.

+36

thanks for your answer 😄😄🌌👍

+33

thanks for all answer 😄😄

+27

thanks 😄😄🌌👍

+25

thanks Andrew G 😄😄🌌👍

+24

+22

You're more than welcome. If you know JavaScript already, jQuery is what you would call a Godsend. Just be warned though, once you get good at jQuery, you'll shudder at having to use vanilla JS again. :D Btw, another cool thing about jQuery is that you can chain things together. EXAMPLE: $(selector).hide().show() ^Instead of writing out multiple lines, you can chain them together like that and it'll execute it as if it was two separate statements. As far as I know, I don't think there is a limit to how many you can chain together. Obviously, do it when it's appropriate and related, and it'll save you some time / lines of code.

+17

"#" for ids and "." for classes

+13

@Netkos Ent nice info . I used JQuery. but I didn't know about chain thing . Thanx 😊😊😊

+11

what is use?

+8

Useful keyword : $(document).ready(function(){ }); 😊😊

+7

.attr() ↑ It's Godsent. With boring old JavaScript and HTML, you could only set and manipulate one id value per element. But with Jquery's "$(selector).attr()", you can get and change the id value of any element. Also, you can create a custom attribute, set a value to it, and then manipulate it. Example: >>HTML <span id="example" num="one" > example </span> >>JS (jquery) var custom_attr = $("span").attr("num"); alert(custom_atrr); //alerts "one" //here, I got the value of a custom attribute. $("span").attr("id", "first_example"); alert( $("span").attr("id") ); //alerts "first_example" //↑ here, I changed the id of an element.

+6

@kapil yadav, jquery is js library, and with 4 lines of js you do 1 line of jqury. go see my code to know more

+5

it's a javascript library that make javascript easier to use.

+5

bookmarked

+4

ajax! is so sweet 😀👍

+4

dont forget to bring the src= script

+3

@Claudio You got that right :D That was one of the happiest days of my life.

+3

$😄😄