working on it ...

Filters

Explore Public Snippets

Sort by

Found 16k snippets matching: dom

    public by afelicioni  362694  0  4  0

    second level domain trick

    second level domain trick: .htaccess
    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    
    #RewriteCond %{HTTP_HOST} !www.dns.it
    #RewriteCond %{HTTP_HOST} (.*).dns.it
    #RewriteRule ^(.*)$ %1/$1
    
    RewriteCond %{HTTP_HOST} whois.dns.it
    RewriteCond %{REQUEST_URI} !_whois/
    RewriteRule ^(.*)$ _whois/$1 [L]
    
    RewriteCond %{HTTP_HOST} tld-info.dns.it
    RewriteCond %{REQUEST_URI} !_tld-info/
    RewriteRule ^(.*)$ _tld-info/$1 [L]
    
    RewriteCond %{HTTP_HOST} tld.dns.it
    RewriteCond %{REQUEST_URI} !_tld-info/
    RewriteRule ^(.*)$ _tld-info/$1 [L]
    
    

    public by HeathDernovich  236823  0  4  1

    Fastest way to add new nodes to the DOM

    Fastest way to add new nodes to the DOM: frag.js
    var frag = document.createDocumentFragment();
    
    ajaxResult.items.forEach(function(item) {
        // Create the LI element
        var li = document.createElement('li');
        li.innerHTML = item.text;
    
        // Do some normal node operations on the LI here,
        // like add classes, modify attributes, 
        // add event listeners, add child nodes, etc.
    
        // *Instead place the LI into the fragment*
        frag.appendChild(li);
    });
    
    // Lastly, mass-inject all list items via the DocumentFragment
    document.querySelector('ul').appendChild(frag);
    
    

    public by micurs  6176  16  8  6

    Using promise() with JQuery animate

    With jQuery 1.5 the $.ajax implements the Promise interface. So you can use done() fail() and always() on the returned promise object returned from the ajax call. You can do the same when invoking the animate() function. The animate function returns the collection of elements the animate() is acting on, so you can create the promise explicitly
    // Shows an alert at the end of an animation.
    $('#myElement').animate( {  height: 200 + 'px'}, 500)
      .promise()
      .done( function () {
        alert('Animation complete!');
      });
    
    

    public by sTiLL-iLL  3407  1  5  6

    Fastest way to add new nodes to the DOM

    Fastest way to add new nodes to the DOM: frag.js
    var frag = document.createDocumentFragment();
    
    ajaxResult.items.forEach(function(item) {
        // Create the LI element
        var li = document.createElement('li');
        li.innerHTML = item.text;
    
        // Do some normal node operations on the LI here,
        // like add classes, modify attributes, 
        // add event listeners, add child nodes, etc.
    
        // *Instead place the LI into the fragment*
        frag.appendChild(li);
    });
    
    // Lastly, mass-inject all list items via the DocumentFragment
    document.querySelector('ul').appendChild(frag);
    
    

    public by JKCPR  2308  1  6  3

    vanilla JS event handler and DOM selection

    Firstly select element from DOM and assign to var. Secondly store anon function in var for executing later. Thirdly assign event handler to first var used in DOM selection and give it the value of the var storing the anon function. In short : identify item and name it, stipulate desired behaviour and lastly give the eventHandler the behaviour to pe
    //js Event Handler assigned to page Element
    
    var theThing = document.getElementById("monsterInQuestion");
    var growls = function(){
      console.log('Grrrrr');
    }
    theThing.onclick = growls;

    public by rfornal  2423  1  6  1

    Simple: Alternate Row Colors (cn be used for ordered list [li], unordered list[li], or tables [using tr]). More correct than nth-of-type which can get dicey when selecting DOM elements. The LI and TR can be switched to almost any HTML tag.

    li:nth-child(even) {
      background-color: red;
    }
    li:nth-child(odd) {
      background-color: white;
    }
    
    tr:nth-child(even) {
      background-color: red;
    }
    tr:nth-child(odd) {
      background-color: white;
    }
    

    public by teslamint  1832  0  3  0

    Javascript-less DOM Debugger for HTML5

    Javascript-less DOM Debugger for HTML5: debug.css
    div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video { outline: #FF0000 dotted 1px !important; }
    
    

    public by jaehoon  1429  0  3  0

    Javascript-less DOM Debugger for HTML5

    Javascript-less DOM Debugger for HTML5: debug.css
    div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video { outline: #FF0000 dotted 1px !important; }
    
    

    public by JKCPR  465  1  5  1

    is your DOM classy? Wouldn't your console like to know...

    Intended as Dev Tool to be utilised in the browser console so that refactoring your messy CSS can be less hurty.
    ;( 
      function (){
      "use strict";
    
      //get ALL DOM elements => BODY > *, BODY *
      var elms = document.body.getElementsByTagName("*"),
          i = elms.length,
          arr = [],
          classArray;
      
      //iterate, isolate, finally indicate
      while( i-- ) {
          classArray = elms[i].className.split(/\s+/);
          if (classArray.length > 1) {
              arr.push( classArray[1] );
          }
      }
      
      console.log( arr.join(',') );
      return arr;
      
    })();

    public by cghersi  3319  2  6  1

    Retrieve the domain of an email in MS SQL Server

    Suppose you have a table with an 'Email' field: here is the way to retrieve just only the domain of that email, and the name of the domain without the extension (.com, .net, etc.)
    select 
      SUBSTRING(Email, 
        charindex('@', Email, 0) + 1, 
        (charindex('.', Email, charindex('@', Email, 0)) - charindex('@', Email, 0)) - 1
      ) as domainWithNoExt, 
      SUBSTRING(Email, charindex('@', Email, 0) + 1, 200) as domain
    from MyTable
    • Public Snippets
    • Channels Snippets