Amit D

Amit D

58 Articles Published

Articles by Amit D

58 articles

How to call a function inside a jQuery plugin from outside?

Amit D
Amit D
Updated on 24-Mar-2026 996 Views

When building jQuery plugins, you often need to expose internal methods so they can be called from outside the plugin. This is achieved by returning an object containing the methods you want to make publicly accessible. Basic Plugin Structure A jQuery plugin that exposes methods typically follows this pattern − it returns an object with the functions you want to access externally ? $.fn.pluginName = function(options) { var settings = $.extend({ // default options }, options); ...

Read More

How to wrap first few items in div using jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 744 Views

To wrap first few items in div, use the :lt selector and to wrap, use the wrapAll() method. The :lt() selector selects elements at an index less than the specified number, while wrapAll() wraps all matched elements together with a single wrapper element. The :lt() selector is zero-indexed, meaning :lt(4) selects the first 4 elements (indices 0, 1, 2, and 3). This makes it perfect for targeting a specific number of items from the beginning of a collection. Example You can try to run the following code to learn how to wrap first few list items in ...

Read More

How to wrap and unwrap HTML control with a div dynamically using jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 612 Views

To wrap HTML control, use the wrap() method and unwrap() method to unwrap HTML control. The wrap() method wraps each selected element with the specified HTML element, while unwrap() removes the parent element of the selected elements. Syntax The basic syntax for wrapping and unwrapping elements − // Wrap elements $(selector).wrap(wrappingElement); // Unwrap elements $(selector).unwrap(); Example You can try to run the following code to wrap and unwrap HTML control with a div dynamically using jQuery − ...

Read More

How to create wrapper div around two other divs with jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 662 Views

To create wrapper div around two other divs, use the wrapAll() method. The wrapAll() method wraps a single HTML structure around all matched elements in the set. This is particularly useful when you want to group multiple elements together within a common container. Syntax The basic syntax of the wrapAll() method is − $(selector).wrapAll(wrappingElement) Where wrappingElement can be an HTML string, DOM element, or jQuery object that will serve as the wrapper. Example You can try to run the following code to create wrapper div around two other divs with jQuery − ...

Read More

How to load a page in div using jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 2K+ Views

To load a page in div in jQuery, use the load() method. The load() method allows you to load external HTML content directly into a selected element. Firstly, add the web page you want to add. Here's the code for new.html − This is demo text. Example Now, the code snippet for the file which adds the above page − ...

Read More

How to load external website into an using jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 45 Views

To load an external website into an using jQuery, use the attr() method to dynamically set the src attribute of the iframe element. This approach allows you to change the iframe content programmatically after the page loads. Basic Implementation The attr() method in jQuery allows you to get or set any HTML attribute. For iframes, setting the src attribute will load the specified URL into the frame. Example You can try to run the following code to learn how to load an external website into an iframe − ...

Read More

How to change the background image using jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 3K+ Views

To change the background image using jQuery, use the jQuery css() method. The background-image CSS property is used to change background image. Syntax The basic syntax to change background image using jQuery is − $(selector).css("background-image", "url('path/to/image.jpg')"); Example You can try to run the following code to learn how to change background image using jQuery − body { height: ...

Read More

How to disable a particular jQuery event on a page?

Amit D
Amit D
Updated on 13-Mar-2026 654 Views

To disable a particular jQuery event, use the jQuery off() method. The off() method removes event handlers that were attached with the on() method. This is particularly useful when you need to dynamically control event behavior based on user interactions or application state. Syntax The basic syntax for the off() method is − $(selector).off(event, selector, function) Where: event − Specifies the event type to remove (e.g., "click", "mouseover") selector − Optional. Specifies which event handler to remove for delegated events function ...

Read More

How to change the background color using jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 10K+ Views

To change the background color using jQuery, use the jQuery css() property. We will change background color on mouse hover with the jQuery on() and css() method. Understanding jQuery css() Method The css() method in jQuery allows you to get or set CSS properties of selected elements. To change background color, you can use css("background-color", "colorvalue") where colorvalue can be a color name, hex code, or RGB value. Example You can try to run the following code to learn how to change background color using jQuery − ...

Read More

How to underline a Hyperlink on Hover using jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 702 Views

To underline a hyperlink on hover using jQuery, use the jQuery css() method. The text-decoration property is used to control the underlining effect. The hover() method in jQuery allows you to specify functions that execute when the mouse enters and leaves an element. You can use this method along with css() to dynamically change the text decoration of hyperlinks. Example You can try to run the following code to learn how to underline a hyperlink on hover − jQuery Hyperlink Decoration ...

Read More
Showing 1–10 of 58 articles
« Prev 1 2 3 4 5 6 Next »
Advertisements