DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:jqueryfaq

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:jqueryfaq [2023-10-19 23:21] – [addEvent()] Klap-indevel:jqueryfaq [2023-10-19 23:36] (current) Klap-in
Line 49: Line 49:
 /* New code */ /* New code */
 var $obj = jQuery('#some__id'); var $obj = jQuery('#some__id');
-// $obj is a jQuery object - if you really need the DOM object use [0] like this:+// $obj is a jQuery object - if you really need the DOM object use [0] e.g.:
 var obj = $obj[0]; var obj = $obj[0];
 </code> </code>
Line 61: Line 61:
 var htmlelements = getElementsByClass( 'class', document, 'tag'); var htmlelements = getElementsByClass( 'class', document, 'tag');
 // htmlelements now is an array of DOM elements // htmlelements now is an array of DOM elements
-for( var n in htmlelements ) {+for(var n in htmlelements ) {
   dosomething( htmlelements[n] );   dosomething( htmlelements[n] );
 } }
  
 /* New code */ /* New code */
-jQuery('tag.class').each(function(){dosomething(this);});+jQuery('tag.class').each(function(){ 
 +    dosomething(this); 
 +});
  
 /* Or, this new code */ /* Or, this new code */
-var jqueryelements = jQuery('tag.class'); +let $jqueryelements = jQuery('tag.class'); 
-// jqueryelements is a jquery thing : an array plus some other stuff. +// $jqueryelements is a jquery thing: an array plus some other stuff. 
-jqueryelements.each(function(){dosomething(this);});+$jqueryelements.each(function(){ 
 +    dosomething(this); 
 +});
 /* or, if you prefer (I don't know wich one is better) */ /* or, if you prefer (I don't know wich one is better) */
-for ( var n = 0; n < jqueryelements.length; ++n ) { +for (let n = 0; n < $jqueryelements.length; ++n ) { 
- dosomething(jqueryelements[n]);+    dosomething($jqueryelements[n]);
 } }
 </code> </code>
  
 +  * It common to start the variable which contain a jQuery object with a ''$''-character, but it is not required.
 ==== addInitEvent() ==== ==== addInitEvent() ====
  
Line 167: Line 172:
  
 Yes, of course. Simply override our default jQuery UI CSS in your own template CSS files. The default theme used by DokuWiki can be found in ''lib/scripts/jquery/jquery-ui-theme/smoothness.css''. Do not edit this file! Override styles in your own template instead. Yes, of course. Simply override our default jQuery UI CSS in your own template CSS files. The default theme used by DokuWiki can be found in ''lib/scripts/jquery/jquery-ui-theme/smoothness.css''. Do not edit this file! Override styles in your own template instead.
-    * override styles in CSS of your template+    * override styles in CSS of your template. See also [[devel:css#dokuwiki stylesheets]] for details.
  
  
devel/jqueryfaq.1697750463.txt.gz · Last modified: 2023-10-19 23:21 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki