Tags: DOM

Sort by: Date / Title /

  1. 1 month ago by spirit
    1. function walkDom($node, $level = 0) {
    2.         $indent = '';
    3.         for ($i = 0; $i < $level; $i++)
    4.         $indent .= '&nbsp;&nbsp;&nbsp;&nbsp;'; //prettifying the output
    5.         if (true /*$node->nodeType == XML_TEXT_NODE*/) {
    6.                 echo $indent.'<b>'.$node->nodeName.'</b> - |'.$node->nodeValue.'|';
    7.  
    8.                 if ( $node->nodeType == XML_ELEMENT_NODE ) {
    9.                         $attributes = $node->attributes; // get all the attributes(eg: id, class)
    10.                         foreach($attributes as $attribute) {
    11.                                 echo ', '.$attribute->name.'='.$attribute->value;
    12.                         }                                                    
    13.                 }
    14.  
    15.                 echo '<br />';
    16.         }
    17.  
    18.         $cNodes = $node->childNodes;
    19.         if (count($cNodes) > 0) {
    20.                 $level++ ; // go one level deeper
    21.                 foreach($cNodes as $cNode)
    22.                         walkDom($cNode, $level);
    23.                 $level = $level - 1;
    24.         }
    25. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2092"></script>
  2. 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>
  3. 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>
  4. sponsorised links
  5. 2 years ago by thanh
    1. " Depuis un fichier
    2. Set xmlDoc = CreateObject("Microsoft.XMLDOM")
    3. xmlDoc.async = False
    4. xmlDoc.load("fichier.xml")
    5.  
    6. " Depuis une chaine
    7. chaine = "<memos>" & "<memo>numéro 1</memo>" & "<memo>numéro  2</memo>" & "</memos>"
    8. xmlDoc = CreateObject("Microsoft.XMLDOM")
    9. xmlDoc.async = False
    10. xmlDoc.loadXML(chaine)
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/350"></script>
  6. 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>

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