Herramientas de usuario

Herramientas del sitio


wiki2:js_dom

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
wiki2:js_dom [2019/02/19 13:52]
alfred [Vanilla]
wiki2:js_dom [2020/05/09 09:25] (actual)
Línea 1: Línea 1:
 ====== Lets avoid jQuery ====== ====== Lets avoid jQuery ======
 +  * https://​htmldom.dev/  ​
   * http://​youmightnotneedjquery.com/​   * http://​youmightnotneedjquery.com/​
 +  * https://​github.com/​nefe/​You-Dont-Need-jQuery | {{:​wiki2:​js:​you-dont-need-jquery-master.zip|}}
 +  * https://​news.ycombinator.com/​item?​id=19534060
  
 ===== Vanilla ===== ===== Vanilla =====
Línea 15: Línea 18:
 <​code>​ <​code>​
 (function() { (function() {
-  // here!+   // your page initialization code here 
 +   // the DOM will be available ​here
 })(); })();
 +</​code>​
 +If supported, it tries the standard:
 +<​code>​document.addEventListener('​DOMContentLoaded',​ fn, false);</​code>​
 +with a fallback to:
 +<​code>​
 +window.addEventListener('​load',​ fn, false )
 +</​code>​
 +or for older versions of IE, it uses:
 +<​code>​
 +document.attachEvent("​onreadystatechange",​ fn);
 +</​code>​
 +with a fallback to:
 +<​code>​
 +window.attachEvent("​onload",​ fn);
 </​code>​ </​code>​
 ===== Selectores ===== ===== Selectores =====
Línea 54: Línea 72:
 ===== Eventos ===== ===== Eventos =====
 Add event: ''​ document.getElementById('​the_id'​).setAttribute('​onchange',​ '​javascript:​loadElements(this,​ event);'​);''​ Add event: ''​ document.getElementById('​the_id'​).setAttribute('​onchange',​ '​javascript:​loadElements(this,​ event);'​);''​
 +
 +==== Bloquear ====
 +<code javascript>​
 +    function filterKeys(ctrl,​ event) {
 +        if (event.key === ','​) event.preventDefault();​
 +    }
 +    <input type="​text"​ value="​tralara"​ width="​100px"​ onkeydown="​filterKeys(this,​ event)"​ />
 +</​code>​
 +
 +Also: ''​event.stopPropagation()''​
 ===== Propiedades ===== ===== Propiedades =====
  
wiki2/js_dom.1550584343.txt.gz · Última modificación: 2020/05/09 09:25 (editor externo)