jQuery Articles

Page 12 of 42

How can I get the selected value of a drop-down list with jQuery?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 8K+ Views

With jQuery, it's easy to get selected text from a drop-down list. This is done using the select id. To get the selected value of a drop-down list, use the val() method, and to get the selected text, use the text() method with the :selected selector. Getting Selected Value and Text There are several ways to retrieve information from a selected dropdown option − Getting Selected Value: Use $("#selectId").val() to get the value attribute of the selected option. Getting Selected Text: Use $("#selectId option:selected").text() to get the display text of the selected option. Example ...

Read More

How to animate scrollLeft using jQuery?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 2K+ Views

To animate scrollLeft using jQuery, use the animate() method with scrollLeft property. The scrollLeft property sets or returns the horizontal scrollbar position for selected elements, making it useful for creating smooth horizontal scrolling animations. Syntax The basic syntax for animating scrollLeft is − $(selector).animate({ scrollLeft: value }, duration, callback); Where value is the target horizontal scroll position, duration is the animation time in milliseconds, and callback is an optional function to execute when animation completes. Example You can try to run the following code to learn how to ...

Read More

How to set scroll left position in jQuery?

Nizam Techs
Nizam Techs
Updated on 13-Mar-2026 309 Views

The scrollLeft() method in jQuery allows you to get or set the horizontal scroll position of an element. When you pass a value to this method, it sets the scroll position from the left edge of the element. Syntax To set the scroll left position, use the following syntax − $(selector).scrollLeft(position) Where position is the number of pixels to scroll from the left edge. Basic Example Here's a simple example that demonstrates how to set the scroll left position − ...

Read More

How to implement jQuery ScrollLeft with easing?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 307 Views

To implement jQuery ScrollLeft, use the jQuery Easing plugin. The easing plugin is used for animation and provides smooth scrolling effects with various animation styles. You need to first add the Easing Plugin library. Let's add the CDN − What is ScrollLeft? The scrollLeft property sets or returns the number of pixels an element's content is scrolled horizontally. When combined with jQuery's animate() method and easing functions, it creates smooth horizontal scrolling animations. Example You can try to run the following code to implement jQuery ScrollLeft with easing − ...

Read More

What is the difference between width and innerWidth in jQuery?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 349 Views

Width in jQuery refers to the horizontal measurement of an element's content area. The width() method returns or sets the width of an element, excluding padding, border, and margin. innerWidth in jQuery returns the inner width of an element, which includes the content width plus the left and right padding, but excludes the border and margin. Key Differences The main difference between width() and innerWidth() is − width() − Returns content width only ...

Read More

What is difference between innerWidth and outerWidth in jQuery?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 342 Views

innerWidth in jQuery The innerWidth() method returns the inner width of the first matched element. It includes padding, but excludes border and margin. This method is useful when you need to calculate the content area plus padding of an element. Example You can try to run the following code to get the inner width in jQuery − ...

Read More

What is the difference between height and outerHeight in jQuery?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 2K+ Views

height() in jQuery The height() method returns the vertical measurement of an element's content area. It excludes padding, border, and margin, giving you only the inner height of the element. To get the height of an element in jQuery, use the height() method. Example You can try to run the following code to get the height − ...

Read More

How to set width and height of an element using jQuery?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 4K+ Views

To set the width and height of an element using jQuery, use the width() and height() methods in jQuery. These methods allow you to dynamically modify element dimensions with pixel values or other CSS units. Setting Width of an Element The width()

Read More

How jQuery selects elements using CSS?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 557 Views

jQuery uses CSS selectors to select and manipulate elements on a web page. This powerful feature allows you to target HTML elements using the same syntax you would use in CSS stylesheets. The css(name) method returns a style property value from the first matched element. CSS Selector Syntax jQuery follows standard CSS selector patterns to identify elements − $("element") − Selects all elements of a specific type $("#id") − Selects element by ID $(".class") − Selects elements by class name $("element.class") − Selects elements ...

Read More

How to define multiple CSS attributes in jQuery?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 2K+ Views

To define multiple CSS attributes in jQuery, use the css() method or the addClass() method. Let's see how to do it using the css() method. When using the css() method to set multiple properties, you need to pass an object where you pair up strings representing property names with their corresponding values. This allows you to modify several CSS properties at once in a single jQuery statement. Example You can try to run the following code to learn how to define multiple CSS attributes in jQuery − ...

Read More
Showing 111–120 of 413 articles
« Prev 1 10 11 12 13 14 42 Next »
Advertisements