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
Articles by Amit D
Page 2 of 6
How to change the 'text-decoration' property with jQuery?
To change the text-decoration property with jQuery, use the jQuery css() method. This method allows you to dynamically modify CSS properties of HTML elements, including text decoration styles like underline, overline, line-through, or none. Syntax The basic syntax to change text-decoration property is − $(selector).css("text-decoration", "value"); Where value can be underline, overline, line-through, or none. Example You can try to run the following code to change text-decoration property from ...
Read MoreHow to make text bold, italic and underline using jQuery
To make text bold, italic and underline using jQuery, use the jQuery css() method with the CSS properties font-style, font-weight and text-decoration. The css() method allows you to dynamically modify CSS properties of HTML elements. Here are the key CSS properties used for text formatting − font-weight − Set to "bold" to make text bold font-style − Set to "italic" to make text italic text-decoration − Set to "underline" to underline text Example You can try to run the following code to ...
Read MoreHow can I change the font family and font size with jQuery?
To change the font family and font size with jQuery, use the jQuery css() method. The CSS properties font-family and font-size are used to modify the typography of elements dynamically. Basic Syntax The css()
Read MoreHow can I change the text color with jQuery?
To change the text color with jQuery, use the jQuery css() method. The color CSS property is used to change text color. Syntax The basic syntax for changing text color using jQuery is − $(selector).css("color", "color-value"); Where selector is the element you want to target and color-value can be a color name, hex code, RGB value, or any valid CSS color format. Example You can try to run the following code to learn how to change text color with jQuery − ...
Read MoreHow to return variable value from jQuery event function?
You cannot return variable value from jQuery event function. To understand the reason, let us see how data is passed, which was created in the event handler of a button click. The main issue is that event functions in jQuery are asynchronous, meaning they execute after the main code flow has completed. When you try to return a value from an event handler, there's nothing to receive that return value since the calling function has already finished executing. Understanding the Problem Event handlers work differently from regular functions because they are callback functions that get executed when ...
Read MoreWhat are jQuery events .load(), .ready(), .unload()?
jQuery load() method The .load() method is used to attach an event handler to the load event. This event occurs when an element and all its child elements have completely loaded, including images, scripts, and stylesheets. Example You can try to run the following code to learn how to work with jQuery .load() method − Note: The .load() method was deprecated in jQuery 1.8 and finally removed in jQuery 3.0. To run the following code, add jQuery ...
Read MoreHow to trigger the same function with jQuery multiple events?
To trigger the same function with multiple events, use the jQuery on() method with multiple events such as click, dblclick, mouseenter, mouseleave, hover, etc. The on() method provides a flexible way to attach event handlers to elements. You can bind multiple events to the same element using an object notation where each property represents an event type and its corresponding handler function. Example You can try to run the following code to learn how to work the same function with jQuery multiple events − ...
Read MoreHow to check which key has been pressed using jQuery?
To check which key has been pressed in jQuery, you can use the keydown, keyup, or keypress event handlers. The most common approach is to use the keydown event, which fires when a key is pressed down. Using jQuery Event Handlers jQuery provides several methods to detect key presses. You can bind event listeners to elements and capture the key information from the event object. The event.key property returns the value of the key pressed. Example You can try ...
Read MoreHow to prevent the browser from executing the default action in jQuery?
To prevent the browser from executing the default action in jQuery, use the preventDefault() method. The preventDefault() method prevents the browser from executing the default action associated with an event, such as following a link, submitting a form, or checking a checkbox. Example The following example demonstrates how to prevent a link from navigating to its href destination. You can also use the method isDefaultPrevented() to know whether this method was ever called on that event object − jQuery preventDefault() ...
Read MoreHow can I remove all elements except the first one using jQuery?
To remove all elements except the first one, use the remove() method with the slice() method in jQuery. The slice(1) method selects all elements starting from index 1 (the second element), leaving the first element untouched. Example You can try to run the following code to remove all elements except for first one using jQuery − $(document).ready(function(){ $(".button1").click(function(){ ...
Read More