tinymce remove auto p tags setting
this is the setting to remove the automatic p tag's when pressing enter and forces the use of br tags instead which can also be toggled, if you dont want it to add anything.
basic for loop odd numbers
a basic for loop with odd numbers adding to an array
check if something is an array
this function will check if something is an array
getType function for js
this function returns the type of item, array object string number etc
card counting example from fcc
here is a solved version of the card counting function from free code camp you can test it using console log.
using switch with multiple identical cases
this can be used if you have several outcomes where the return value will be the same by omitting the break from the cases before the final
using switch in a function
This shows an example using the switch to select multiple options in a function, you can return from the switch with break, or you can end the whole function with return.
js function to calculate golf scores
this function will return the score name depending on the par and strokes for golf
compare non equality function
this will check if two values are not equal
compare equality function
this will check if two values are exactly equal
JS Using typeof to check on string types
you can use the typeof operator to check what kind of variables you have.
showing the difference between == and === operators
defining a variable inside a function without using var will create a global variable
here is an example showing a variable defined within a function showing how it becomes a global variable if not defined with var
add something to the start of an array with unshift
unshift is the opposite of push where push adds to the end of an array unshift will add to the start of the array.
remove the first element in an array with shift
like pop but shift does the 1st element in an array
this is a version of a dom ready or document ready that does not require jquery
a one liner to add a class name to an element with a specific id, for this to run it seems to need a document ready.
using local storage rather than cookies to store data (localStorage)
you can see what is stored in local storage by typing this into your browser console. localStorage Adding something You can add something to local storage by using the setItem function.
remove something from the end of an array with pop
pop is the opposite of push and will remove the last item in an array, it also returns the value so you can assign it to a variable
add something to the end of an array with push
get the last letter of a string
you can use the .length and the index of a string to get its last value
accessing part of a variable using its index
you can access part of a string variable using its index
js check the length of a string
Dropdown Box with Searchable Text
using parse_url to extract parts of a url
Category: PHP the parse_url php function will split a url into an array of url fragments $url = "http://kruxor.com/path/?argument=value#anchor"; var_dump(parse_url($url)); parse_url example ..
This usually goes in the theme functions file. This will load it after jquery if it requires it. wp_register_script('scriptname', get_template_directory_uri() . '/js/scripts.js', array('jquery'), ..
google map with overlay data
Ever wanted to add a really slightly complex google map to your site? Working Example /* Always set the map height explicitly to define the size of the div * element that con..
slick slider carousel
Nice and simple slider / carousel Slick Example <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css"/> <link rel="s..
set and check a cookie using js cookie
show the year with js
just a simple one liner that will show the current year, so no more need for static years in html footers! var d = new Date(); document.getElementById("year").innerHTML = d.getFullYear(); Usage E..
simple dropdown multi level navigation ul li css
updated to work standalone and not effect other list elements on the page