-
The submit() Method
The jQuery submit() method attach an event handler function to the <form> elements that is executed when the user is attempting to submit a form. The following example will display a message depending on the value entered when you try to submit the form. Example Tip: A form can be submitted either by clicking a submit button, or by pressing…
-
Keyboard Events
A keyboard event is fired when the user press or release a key on the keyboard. Here’re some commonly used jQuery methods to handle the keyboard events. The keypress() Method The jQuery keypress() method attach an event handler function to the selected elements (typically form controls) that is executed when the browser receives keyboard input from the user. The…
-
jQuery Events
What are Events Events are often triggered by the user’s interaction with the web page, such as when a link or button is clicked, text is entered into an input box or textarea, selection is made in a select box, key is pressed on the keyboard, the mouse pointer is moved etc. In some cases,…
-
Selecting Elements by Attribute
You can use the attribute selector to select an element by one of its HTML attributes, such as a link’s target attribute or an input’s type attribute, etc. For example, the following jQuery code will select and highlight all the text inputs i.e. <input> elements with the type=”text”, when the document is ready. Example Selecting Elements by Compound CSS Selector You can…
-
jQuery Selectors
Selecting Elements with jQuery JavaScript is most commonly used to get or modify the content or value of the HTML elements on the page, as well as to apply some effects like show, hide, animations etc. But, before you can perform any action you need to find or select the target HTML element. Selecting the…
-
jQuery Syntax
Standard jQuery Syntax A jQuery statement typically starts with the dollar sign ($) and ends with a semicolon (;). In jQuery, the dollar sign ($) is just an alias for jQuery. Let’s consider the following example code which demonstrates the most basic statement of the jQuery. Example The above example simply displays an alert message…
-
Including jQuery from CDN
Alternatively, you can include jQuery in your document through freely available CDN (Content Delivery Network) links, if you don’t want to download and host jQuery yourself. CDNs can offer a performance benefit by reducing the loading time, because they are hosting jQuery on multiple servers spread across the globe and when a user requests the…
-
jQuery Getting Started
Downloading jQuery To get started, first download a copy of jQuery and include it in your document. There are two versions of jQuery available for downloading — compressed and uncompressed. The uncompressed file is best suited for development or debugging; while, the minified and compressed file is recommended for production because it saves the precious bandwidth and improves…
-
Advantages of Using jQuery
If you’re not familiar with jQuery, you might be wondering what makes jQuery so special. There are several advantages why one should opt for jQuery: Tip: In JavaScript, you often need to write several lines of code to select an element in an HTML document, but with jQuery robust selector mechanism you can traverse the DOM…
-
jQuery Introduction
jQuery is a fast, lightweight, and feature-rich JavaScript library that is based on the principle “write less, do more”. It’s easy-to-use APIs makes the things like HTML document traversal and manipulation, event handling, adding animation effects to a web page much simpler that works seamlessly across all the major browsers like Chrome, Firefox, Safari, Internet Explorer,…