Welcome To Snipplr
Everyone's Recent JavaScript Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
<p><div id="calc">
<p><b>VAT rate:</b>
<input type="text" id="vat_rate" placeholder="20" size="10" value>
<p><b>Net price:</b>
<input type="text" id="net_price" size="10" value>
<p><b>Gross price:</b>
<input type="text" id="gross_price" size="1...
        
        
        
            0 
        
        
            21244 
        
                    posted 5 years ago by antonykidless
            This is used to validate a date in a specific format. The code example is to validate whether it is a valid dd/MM/yyyy Date Format.
        
        
        
            1 
        
        
            28325 
        
                    posted 5 years ago by jlustre
            JavaScript is a client-side as well as server side scripting language that can be inserted into HTML pages and is understood by web browsers. JavaScript is also an Object based Programming language.
Example
Note: This is an example, you can change...
        
        
        
            0 
        
        
            18301 
        
                    posted 5 years ago by priyagchaudhary
            
            JavaScript
        
            JQuery - how to wait for the \"end\" of the \"resize\" event and only then perform the action?  
        
                    The resizeend event.
It works for me
        
        
        
            0 
        
        
            29762 
        
                    posted 6 years ago by cerxx
            There is no need to use jQuery particularly to manipulate cookies.
        
        
        
            0 
        
        
            7374 
        
                    posted 6 years ago by cerxx
            Here is a code that force to fire a click on iOS devices, where there is first a touchstart event
        
        
        
            0 
        
        
            3588 
        
                    posted 6 years ago by cerxx
            JavaScript regex for validating IP addresses, has been tested!
        
        
        
            0 
        
        
            3510 
        
                    posted 7 years ago by plasticbottle
            This snippet code allows you to prevent the viewer from being able to right-click on your page. This can discourage the average user from borrow images or code from your site.
        
        
        
            0 
        
        
            3544 
        
                    posted 8 years ago by apphp-snippets
            How to pass a parameter into a method from an onClick method found in the render method.
Majority of the times when you need to do this, your adding it through a loop.  In this case, call a function where the item in the loop will automatically be...
        
        
        
            0 
        
        
            3681 
        
                    posted 8 years ago by heathbo
            ResponsiveBootstrapToolkit : https://github.com/maciej-gurban/responsive-bootstrap-toolkit
        
        
        
            0 
        
        
            3371 
        
                    posted 9 years ago by dhjapan
            Filters a dynamics CRM 2011 subgrid...implementation example included at bottom
        
        
        
            0 
        
        
            1558 
        
                    posted 9 years ago by skinnymoore
            Use ref with getDOMNode() to get the actual html.  
Using getBoundingClientRect() on the actual html will give you the width, height, etc.
Below:
specs =  ClientRect {} bottom: 269 height: 18 left: 797.546875 right: 1062.609375 top: 251 width: 2...
        
        
        
            0 
        
        
            4141 
        
                    posted 9 years ago by heathbo
            Within a react component.  How to gain access to the HTML that was just rendered.
Any returned html element that is tagged with a ref, can easily be accessed by it's ref after it's been rendered.  In the below case, use this.refs["domainModal"] to...
        
        
        
            0 
        
        
            3429 
        
                    posted 9 years ago by heathbo
            When creating a new https://codepad.co/ snippet, the default language will be set to 'JavaScript'.
        
        
        
            0 
        
        
            3385 
        
                    posted 9 years ago by avansare
            You know that iFrames are a necessary evil for many of us. When yuo put a third party site in an iframe is always a risk because they can break out of that iframe and redirect the visitor to another location. This code acts as a defense for such case...
        
        
        
            0 
        
        
            3433 
        
                    posted 9 years ago by apphp-snippets
            Sometimes you may want to show the visitor that you are aware of their IP address. You can do so by using few lines of code as shown here. Place the code in any place of your page, where you want the IP address to appear:
        
        
        
            0 
        
        
            3497 
        
                    posted 9 years ago by apphp-snippets
            Array.prototype.forEach
You can't break forEach. So use "some" or "every".
Array.prototype.some
some is pretty much the same as forEach but it break when the callback returns true.
Array.prototype.every
every is almost identical to some except i...
        
        
        
            0 
        
        
            3450 
        
                    posted 10 years ago by Waltem
            Using underscore.js, you could combine .findWhere with .without
Although, since you are creating a new array in this case anyway, you could simply use _.filter or the native Array.prototype.filter function (just like shown in the other question)....
        
        
        
            0 
        
        
            6473 
        
                    posted 10 years ago by Balamir
            // create a variable to toggle debugging
  // to use it, just call debug(with,any,optional,parameters)
  debug(x,y,z);
  // it will try to guess what type of message to log, or you can specify in the first parameter
  debug("error",x,y,z);
        
        
        
            1 
        
        
            3554 
        
                    posted 10 years ago by brandonjp
            To do this for any object in JavaScript will not be simple or straightforward. You will run into the problem of erroneously picking up attributes from the object's prototype that should be left in the prototype and not copied to the new instance. If,...
        
        
        
            0 
        
        
            3577 
        
                    posted 10 years ago by BrentS
            delete Operator don’t impact the length of Array in JavaScript
        
        
        
            1 
        
        
            3540 
        
                    posted 10 years ago by ursdeep
            
