jquery:start
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
jquery:start [2015-01-24 22:18] – [Tutorials] "Kostenpflichtige Tutorials" mit Links zu "video2brain: jQuery", "video2brain: jQuery für Webdesigner", "video2brain: jQuery Mobile: Crashkurs" und "video2brain: jQuery UI für Einsteiger" eingefügt a.kamola | jquery:start [2015-08-14 20:36] (aktuell) – [Snippets] "Smooth-Scrolling" eingefügt a.kamola | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== jQuery ====== | ====== jQuery ====== | ||
+ | |||
+ | //jQuery// ist ein [[javascript: | ||
+ | |||
+ | ===== Initialisierung ===== | ||
+ | |||
+ | <code javascript> | ||
+ | jQuery(document).ready(function($) { | ||
+ | // jQuery code goes here ... | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | ===== DOM-Manipulation ===== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | ==== Element einfügen ==== | ||
+ | |||
+ | <code javascript> | ||
+ | $('# | ||
+ | </ | ||
+ | |||
+ | ==== Element kopieren ==== | ||
+ | |||
+ | <code javascript> | ||
+ | // Element kopieren | ||
+ | var foo = $(' | ||
+ | |||
+ | // Element wieder im DOM einfügen | ||
+ | $(' | ||
+ | </ | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | ==== Inhalt ändern ==== | ||
+ | |||
+ | <code javascript> | ||
+ | $("# | ||
+ | </ | ||
+ | |||
+ | <code javascript> | ||
+ | $("# | ||
+ | </ | ||
+ | |||
+ | ===== CSS ===== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | <code javascript> | ||
+ | $('# | ||
+ | </ | ||
+ | |||
+ | ===== Events ===== | ||
+ | |||
+ | ==== Hover ==== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | ==== Toggle ==== | ||
+ | |||
+ | < | ||
+ | |||
+ | ===== Snippets ===== | ||
+ | |||
+ | ==== ID eines Elements ==== | ||
+ | |||
+ | <code javascript> | ||
+ | var elementID = $('# | ||
+ | </ | ||
+ | |||
+ | ==== ID des Eltern-Elements ==== | ||
+ | |||
+ | <code javascript> | ||
+ | $(this).parent().attr(' | ||
+ | </ | ||
+ | |||
+ | ==== Kind-Elemente von $(this) finden ==== | ||
+ | |||
+ | Bestimmte, untergeordnete Elemente (bspw. bestimmte Klassen) von '' | ||
+ | |||
+ | <code jquery> | ||
+ | $(" | ||
+ | </ | ||
+ | |||
+ | <code jquery> | ||
+ | $(this).find(" | ||
+ | </ | ||
+ | |||
+ | Wenn die Elemente **direkte** Kinder von '' | ||
+ | |||
+ | <code jquery> | ||
+ | $(this).children(" | ||
+ | </ | ||
+ | |||
+ | Quelle: [[http:// | ||
+ | |||
+ | ==== (Direkte) Kind-Elemente eines Elements zählen ==== | ||
+ | |||
+ | <code jquery> | ||
+ | var listItemsCount = $('ul > li' | ||
+ | </ | ||
+ | |||
+ | Quelle: [[http:// | ||
+ | |||
+ | ==== Mausposition ==== | ||
+ | |||
+ | <code javascript> | ||
+ | var currentMousePos = { x: -1, y: -1 }; | ||
+ | |||
+ | $(document).mousemove(function(event) { | ||
+ | currentMousePos.x = event.pageX; | ||
+ | currentMousePos.y = event.pageY; | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | Quelle: [[http:// | ||
+ | |||
+ | ==== Bild austauschen ==== | ||
+ | |||
+ | <code javascript> | ||
+ | $("# | ||
+ | </ | ||
+ | |||
+ | ==== Bild bei Maus-Hover austauschen ==== | ||
+ | |||
+ | <code javascript> | ||
+ | $(" | ||
+ | function() { | ||
+ | this.src = this.src(" | ||
+ | }, | ||
+ | function() { | ||
+ | this.src = this.src(" | ||
+ | } | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | ==== Smooth-Scrolling ==== | ||
+ | |||
+ | <code javascript> | ||
+ | $(' | ||
+ | // Prevent default anchor click behavior | ||
+ | e.preventDefault(); | ||
+ | |||
+ | // Store hash | ||
+ | var hash = this.hash; | ||
+ | |||
+ | // Animate | ||
+ | $(' | ||
+ | scrollTop: | ||
+ | }, 300, function(){ | ||
+ | // when done, add hash to url (default click behaviour) | ||
+ | window.location.hash = hash; | ||
+ | }); | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | Quelle: [[http:// | ||
+ | |||
+ | ===== Cookies ===== | ||
+ | |||
+ | * [[https:// | ||
===== Links ===== | ===== Links ===== | ||
+ | * [[http:// | ||
* [[https:// | * [[https:// | ||
jquery/start.1422134331.txt.gz · Zuletzt geändert: 2015-01-24 22:18 von a.kamola