Tags: javascript,dom

Sort by: Date / Title /

  1. 1 year ago by jacinmontava
    1. <html>
    2. <body>
    3.  
    4. <form id="myForm">
    5. Firstname: <input id="fname" type="text" value="Mickey" />
    6. Lastname: <input id="lname" type="text" value="Mouse" />
    7. <input id="sub" type="button" value="Submit" />
    8. </form>
    9.  
    10. <p>Get the value of all the elements in the form:<br />
    11. <script type="text/javascript">
    12. var x=document.getElementById("myForm");
    13. for (var i=0;i<x.length;i++)
    14.   {
    15.   document.write(x.elements[i].value);
    16.   document.write("<br />");
    17.   }
    18. </script>
    19. </p>
    20.  
    21. </body>
    22. </html>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1297"></script>
  2. 2 years ago by yasakani
    Sencilla, pero util funcion para mostrar u ocultar una capa dentro de una pagina web con javascript. Hay que tener un poco de conocimientos de DOM y CSS.
    1. // MOSTRAR - OCULTAR
    2.        
    3. function mostrarOcultar(id) {
    4.         divID = document.getElementById(id);
    5.         if(divID.style.display == "")
    6.                 divID.style.display = "none";
    7.         else
    8.                 divID.style.display = "";
    9. }
    10.  
    11. // Enlace y Capa
    12.  
    13. <a href="#" onclick="mostrarOcultar('capa'); return false;">Mostrar-Ocultar</a>
    14. <div id="capa" style="display: none;">Contenido de la Capa.</div>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/637"></script>
  3. 2 years ago by spirit
    1. $.create = function() {
    2.   var ret = [], a = arguments, i, e;
    3.   a = a[0].constructor == Array ? a[0] : a;
    4.   for(i=0; i<a.length; i++) {
    5.     if(a[i+1] && a[i+1].constructor == Object) { // item is element if attributes follow
    6.       e = document.createElement(a[i]);
    7.       $(e).attr(a[++i]); // apply attributes
    8.       if (a[i] == 'table') alert ('titi');
    9.       if(a[i+1] && a[i+1].constructor == Array) $(e).append($.create(a[++i])); // optional children
    10.       ret.push(e);
    11.     } else { // item is just a text node
    12.       ret.push(document.createTextNode(a[i]));
    13.     }
    14.   }
    15.  
    16.   return ret;
    17. };
    18.  
    19.  
    20. // Usage
    21. $.create(
    22.    'table', { 'class':"MyTable" }, [
    23.       'tbody', {}, [
    24.          'tr', { 'class':"MyTableRow" }, [
    25.             'td', { 'class':"MyTableCol1" }, [ "howdy" ],
    26.             'td', { 'class':"MyTableCol2" }, [
    27.                "Link:", 'a', { 'class':"MyLink", 'href':"http://www.example.com" }, ["example.com"] ] ],
    28.          'tr', { 'class':"MyTableRow2" }, [
    29.             'td', { 'class':"MyTableCol1" }, [ "howdy" ],
    30.             'td', { 'class':"MyTableCol2" }, [
    31.                "Link:", 'a', { 'class':"MyLink", 'href':"http://www.example.com" }, ["example.com"] ] ] ] ]);
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/115"></script>
  4. sponsorised links

First / Previous / Next / Last / Page 1 of 1 (3 posteets)