Target Every Element…Except One

Sometimes I need to have an action, like closing/hiding a menu, that requires the ability to click anywhere but the div/menu itself in order to take an action. Here is a neat way I found to do such a thing. Thanks Sandeep!

You will of course have to edit this to work for your project.

Javascript Mobile Detection

Found on StackOverflow http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-handheld-device-in-jquery#answer-3540295

Seems to work pretty well. Have not tested on all devices but does work for all Android and iOS devices I tested

Simple Fading Carousel

Usually I am using bootstrap and it’s carousel works pretty well but sometimes I don’t want or don’t have access to the bootstrap carousel. Here is a sample of a basic carousel I have used in a few places.

HTML + PHP

Javascript

LESS

So if you are just visiting and are trying to use this…good luck. I don’t really want to explain some of the functions or what is going on…thankfully I already know 🙂

 

Javascript Contains Prototype

I always hated using the indexof method to detect strings in javascript. I found a nice prototype method which makes these kinds of checks easier.

Returns true or false.

 

Loop Through Multiple File Mimetypes

I needed to check mimetypes to be sure the user knew right away if one of the files they wanted to upload was accepted. Here is (most of) the code I ended up using. You will need to edit to fit your needs.

Here is the HTML being used.

Check out how to get the WordPress mimetype array from PHP into Javascript here.

Copy PHP Array to Javascipt Object

I often need to work with data client side that is returned from the server. Found this neat piece of code which I used to get the available mimetypes so I can validate client side that the file the user is attempting to upload is accepted.