RSSCategory: JavaScript

Aug

8

Get Value of URL Parameters using JavaScript

Posted by Leave a Comment

If you are looking for a quick and easy way to grab the value of a query string parameter from a URL, you only need a few lines of JavaScript. The below script will return the value of the matching parameter or return false if no match was found.

Continue Reading

Feb

22

Check if Element is Hidden with jQuery

Posted by Leave a Comment

You can use jQuery to check if an element on a web page is hidden using $(element).is(":hidden"). This will check both CSS properties and methods such as jQuery’s .hide() or .toggle().

if ($('#elementID').is(':hidden')) {
  // true if element is hidden
}

Continue Reading

Feb

12

Scrolling Floating Sidebar in jQuery

Posted by 10 Comments

Making a sidebar that floats while scrolling for your website is quite simple using jQuery. A very basic markup of HTML, CSS, and Javascript are below. Click on the JS Fiddle link at the bottom to view a demo.

HTML: Two divs, a longer ‘divA’ on the left, and the floating ‘divB’ on the right, both wrapped in a container div.

1
2
3
4
<div id="container">
    <div id="divA"></div>
    <div id="divB"></div>
</div>

Continue Reading

Jan

23

Check if Element Exists Using Javascript or jQuery

Posted by Leave a Comment

To check if an element exists on a page you can use the getElementById method:

if (document.getElementById('theID')) { }

You can also do this by using jQuery’s length method:

if ($('#theID').length) { }