JavaScript Code Snippets

Some JavaScript functions and code snippets useful for JavaScript Programmers and JS scripts.
New JavaScript Code Snippets might be added soon.

  1. Keep the first Nr IMG tags, Remove all the others
  2. Add Text in Canvas from Input text field, as it is Typed
  3. Clear Canvas Context
  4. Get the Height and Width of web Page and browser Window
  5. Detect when ScrollBar reaches the bottom of the page
  6. Add Tag to Selected Text in textarea with JavaScript
  7. Select the Content of HTML Element
  8. Convert BBCode to HTML and HTML to BBCode
  9. Show and Hide HTML elements
  10. Recursive function to create Multi-Level Menu in JavaScript
  11. Highlight Images on click
  12. Disable button and Enable it after specified time
  13. Get Domain Name and other Data from URL
  14. Get search data from URL address in JavaScript
  15. SHA512 Encrypt hash
  16. SHA256 Encrypt hash
  17. SHA1 Encrypt data
  18. MD5 hash string
  19. Base64 encode decode
  20. Split an alphanumeric string into Array
  21. Delete and Add CSS class
  22. Replace JavaScript variable name from string with its value
  23. Get the value of the selected /checked checkboxes in a form
  24. Get Lower, Higher and Closest Number in JavaScript
  25. Difference between two Dates - Time and Date
  26. JavaScript trim, rtrim and ltrim
  27. JS PHP is_ functions to test data type
  28. array_map and array_search in JS
  29. JavaScript strip_tags and stripslashes