Si vous avez travaill? sur de nombreux projets et JavaScript jQuery, vous devez ?tre familier avec de nombreux codes sources Javascript, tel que Class.method1().method2().methodN()
.
- Demo
- Agrandir
- Recharger
- New window
Gratuit iPage hébergement Web pour la première année MOMENT
Si vous êtes toujours à la recherche d'un fournisseur d'hébergement Web fiable avec des tarifs abordables, pourquoi vous ne prenez pas un peu de temps pour essayer iPage, seulement avec $1.89/month, inclus $500+ Crédits supplémentaires gratuites pour le paiement de 24 mois ($45)?
Plus de 1.000.000 de clients + existisng peuvent pas avoir tort, vraiment vous n'êtes pas aussi! Plus important encore, lorsque vous enregistrez l'hébergement web à iPage grâce à notre lien, nous allons être heureux de renvoyer un plein remboursement. C'est génial! Vous devriez essayer iPage hébergement web GRATUITEMENT maintenant! Et contactez-nous pour tout ce que vous devez savoir sur iPage.
JavaScript allows us to chain methods by simply making methods return the this
keyword, that is, themselves. So you can have method1().method2().methodN()
and so on, all members of the same chain. This turns out to be very useful when you want to concatenate some subroutines and, most of all, when you want to keep your code tidy and organized by avoiding functions and methods that make too much. The basic structure is as follows:
var Class = { method1: function() { //... return this; }, method2: function() { //... return this; }, methodN: function() { // end of the chain } };
You can use this technique as follows:
Class.method1().method2().methodN();
A practical example:
var Class = { element: document.getElementById('test'), grow: function() { this.element.style.width = '180px'; this.element.style.height = '180px'; return this; }, move: function() { var counter = 0; var interval = setInterval(function() { counter += 1; Class.element.style.left = counter + 'px'; if(counter == 100) { clearInterval(interval); var interval2 = setInterval(function() { counter -= 1; Class.element.style.left = counter + 'px'; if(counter == 0) { clearInterval(interval2); Class.element.style.width = '150px'; Class.element.style.height = '150px'; } }, 25); } }, 25); }, run: function() { var trigger = document.getElementById('run'); run.onclick = function() { Class.grow().move(); return false; }; } }; Class.run(); };
- Sent (0)
- Nouveau
Save up to 630$ when buy new iPhone 15
GateIO.gomymobi.com
Free Airdrops to Claim, Share Up to $150,000 per Project
https://tooly.win
Open tool hub for free to use by any one for every one with hundreds of tools
chatGPTaz.com, chatGPT4.win, chatGPT2.fun, re-chatGPT.com
Talk to ChatGPT by your mother language
Dall-E-OpenAI.com
Generate creative images automatically with AI
AIVideo-App.com
Render creative video automatically with AI