Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
jQuery Articles
Page 2 of 42
How to Check a String Starts/Ends with a Specific String in jQuery?
JavaScript provides several built-in methods to check if a string starts or ends with specific characters. While jQuery is excellent for DOM manipulation, these string operations are handled by native JavaScript methods that work efficiently without any additional library. In this article, we'll explore various approaches to verify if a string begins or ends with another string using practical examples. Using startsWith() Method The startsWith() method is the most direct way to check if a string begins with specific characters. It's case-sensitive and returns a boolean value. Syntax str.startsWith(searchString, position) Parameters ...
Read MoreHow to Change an HTML Element Name Using jQuery?
jQuery is a JavaScript library created to make event handling, CSS animation, Ajax, and DOM tree navigation and manipulation easier. In this article we are going to see how we can change the name of an element using jQuery. Algorithm We are going to follow a three−way procedure to change the name of any element using jQuery: Identify and select the element we want to change. Copy all the attributes of the selected element to a temporary object. Create a new element with the ...
Read MoreHow to set textarea scroll bar to bottom as a default using JavaScript/jQuery?
In JavaScript, you can set a textarea's scroll bar to the bottom using the scrollTop property. This is useful when you want to automatically show the most recent content, such as in chat applications or log displays. Syntax element.scrollTop = element.scrollHeight; Parameters scrollHeight − Returns the total height of the element's content, including content not visible due to overflow. Method 1: Using Pure JavaScript This approach uses the DOM's scrollTop property to position the scroll bar at the bottom of the textarea. ...
Read MoreHow to check two elements are the same using jQuery/JavaScript?
We can access HTML elements using various methods in vanilla JavaScript or jQuery. Sometimes, after accessing DOM elements, developers need to check if both accessed elements are the same or not. In this tutorial, we will learn to use JavaScript's strict equality operator and jQuery's is() method to check the equality of two HTML elements. Using the Equality Operator (===) in JavaScript We can access HTML elements using methods like getElementById, querySelector, getElementsByClassName, etc. After storing elements in JavaScript variables, we can compare them using the strict equality operator (===). Syntax if (element1 === element2) ...
Read MoreUse jQuery to get values of selected checkboxes?
jQuery provides an efficient way to get values of selected checkboxes using the :checked selector combined with checkbox input elements. This is useful for forms where users can select multiple options. Syntax $('input[type="checkbox"]:checked') // or $('input[name="checkboxName"]:checked') Basic Example Here's a complete example that demonstrates getting values of selected checkboxes: jQuery Checkbox Values Select your hobbies: ...
Read MoreHow to add content in section using jQuery/JavaScript?
Adding content to the section dynamically is useful for loading CSS, JavaScript, or meta tags after page load. jQuery and JavaScript provide several methods to accomplish this task programmatically. There are three main approaches to add content to the head section: Using jQuery's .append() method Using JavaScript's document.createElement() method Using JavaScript's insertAdjacentHTML() method Let's explore each approach with working examples. Using jQuery's .append() Method jQuery's append() method provides a simple way to add content to the head section: ...
Read MoreAdd sizes for Bootstrap Buttons
Bootstrap provides several CSS classes to control button sizes, from large buttons to block-level buttons that span the full width of their container. Button Size Classes Class Description .btn-lg ...
Read MoreHow to fire after pressing ENTER in text input with HTML?
There are several ways to detect when the ENTER key is pressed in a text input field. Here are the most common and effective approaches. Using jQuery with Custom Event This approach creates a custom "enterKey" event that triggers when ENTER is pressed: $(document).ready(function(){ $('input').bind("enterKey", function(e){ ...
Read Moreimg-rounded Bootstrap class
Use the img-rounded Bootstrap class to style your image and give it rounded corners. This class applies CSS border-radius to create smooth, rounded edges on images. Syntax Example Bootstrap Images Styling Images with Bootstrap ...
Read MoreMove an HTML div in a curved path
To move an HTML div in a curved path, you can use CSS animations, JavaScript, or HTML5 Canvas. JavaScript provides the most flexibility and browser compatibility for complex curved animations. CSS Transitions - Simple curved paths using cubic-bezier JavaScript (jQuery) - Custom curved animations with precise control HTML5 Canvas - Complex curved paths with mathematical precision We'll focus on JavaScript solutions using jQuery's animate() method and modern CSS transforms. jQuery animate() Method The animate() method performs custom animations by changing CSS properties over time. ...
Read More