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 AmitDiwan
Page 244 of 840
jQuery.click() vs onClick
In this article, we will learn the difference between jQuery.click() and onClick. The click() method is a jQuery event handler that attaches event listeners dynamically, while onClick is an HTML attribute that defines inline event handling directly in the markup. jQuery click() Method The click() method in jQuery is used to attach a click event handler to selected elements or trigger the click event programmatically. It follows the standard event registration model and allows multiple event handlers to be attached to the same element. Syntax Following is the syntax for the jQuery click() method − ...
Read MoreHow to prevent form from being submitted?
Preventing form submission is essential for client-side validation, custom handling, or multi-step forms. JavaScript provides several methods to prevent the default form submission behavior, allowing developers to validate data, show confirmation dialogs, or handle form data without page reloads. Syntax Following are the common syntaxes to prevent form submission − // Using event.preventDefault() event.preventDefault(); // Using return false return false; // Using addEventListener with preventDefault form.addEventListener('submit', function(e) { e.preventDefault(); }); Method 1 − Using event.preventDefault() The event.preventDefault() method cancels the default action that belongs to the event. When ...
Read MoreHTML DOM Input Time disabled Property
The HTML DOM Input Time disabled property sets or returns whether a time input field is enabled or disabled. When an input time element is disabled, it becomes non-editable and appears grayed out, preventing user interaction. Syntax Following is the syntax for returning the disabled property − inputTimeObject.disabled Following is the syntax for setting the disabled property − inputTimeObject.disabled = booleanValue Parameters Here, booleanValue can be one of the following − Value Description true Disables the input time element (non-editable, grayed ...
Read MoreHTML DOM Input Password required property
The HTML DOM Input Password required property is associated with the required attribute of an element with type="password". This property sets or returns whether a password field must be filled before form submission. When set to true, the browser prevents form submission if the password field is empty and displays a validation message. Syntax Following is the syntax for setting the required property − passwordObject.required = true|false Following is the syntax for getting the required property − var isRequired = passwordObject.required; Parameters The required property accepts the following ...
Read MoreWhy doesn't height: 100% work to expand divs to the screen height?
The height: 100% property in CSS doesn't work as expected for expanding divs to screen height because percentage heights depend on the parent element's height. If the parent doesn't have an explicit height, the percentage calculation fails, and the element won't expand to full screen height. Why height: 100% Fails When you set height: 100% on a div, the browser looks for the parent element's height to calculate the percentage. If the parent element (like or ) doesn't have a defined height, the percentage has no reference point and defaults to the content height instead of the ...
Read MoreHTML DOM Input Time form Property
The HTML DOM Input Time form property returns a reference to the form element that contains the input time field. This property is read-only and provides access to the parent form object, allowing you to retrieve form attributes like ID, name, or other form-related properties. Syntax Following is the syntax for accessing the form property − inputTimeObject.form Return Value The form property returns a reference to the HTMLFormElement object that contains the input time element. If the input time element is not inside a form, it returns null. Example − Getting Form ...
Read MoreCreate A Form Using HTML Tables?
Creating forms using HTML tables was a common practice before CSS became widely adopted. While modern web development favors CSS-based layouts, understanding table-based forms is still valuable for maintaining legacy code and certain specific use cases. Syntax Following is the basic syntax for creating a form using HTML tables − Label: ...
Read MoreHTML DOM Input Time max Property
The HTML DOM Input Time max property sets or returns the value of the max attribute of a time input field. This property defines the maximum time value that a user can enter in the time input field. Syntax Following is the syntax for returning the max property value − inputTimeObject.max Following is the syntax for setting the max property value − inputTimeObject.max = "hh:mm:ss.ms" Property Values The max property accepts a string value representing time in the format hh:mm:ss.ms. Here are the components − ...
Read MoreHTML DOM Input Time min Property
The HTML DOM Input Time min property sets or returns the value of the min attribute of an HTML time input field. This property defines the minimum time value that a user can enter, providing validation to ensure the selected time meets the required criteria. Syntax Following is the syntax for getting the min property value − inputTimeObject.min Following is the syntax for setting the min property value − inputTimeObject.min = "hh:mm:ss.ms" Property Values The min property accepts a time string in the format "hh:mm:ss.ms". The following table describes ...
Read MoreHTML onsubmit Event Attribute
The HTML onsubmit event attribute is triggered when a form is submitted in an HTML document. This attribute allows you to execute JavaScript code when a user submits a form, enabling form validation, data processing, or other custom actions before the form data is sent to the server. Syntax Following is the syntax for the onsubmit event attribute − form content The script parameter contains JavaScript code or a function call that executes when the form is submitted. The function can return false to prevent the form submission or ...
Read More