jQuery .val change doesn't change input value?

AmitDiwan
Published on 14-Jul-2020 16:07:25
For this, you need to use attr(). The attr() method can be used to either fetch the value of an attribute from the first element in the matched set or set attribute values onto all matched elements.Following is the JavaScript code −Example Live Demo<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> ... Read More

How to disable default behavior of <input type=“time”> when you press enter with JavaScript?

AmitDiwan
Published on 14-Jul-2020 15:32:19
For this, you need to use keyDown as well as preventDefault(). Following is the JavaScript code −Example Live Demo<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <input type="time" id="disableDefaultTime"> <script>    const pressEnter = (event) => {   ... Read More

How to disable future dates in JavaScript Datepicker?

AmitDiwan
Published on 14-Jul-2020 15:28:56
In order to disable future dates, you need to use maxDate and set the current date. Following is the JavaScript code −Example Live Demo<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <p>The selected date is as follows: <input ... Read More

Preconditions - Java

AmitDiwan
Published on 14-Jul-2020 10:37:45
Precondition to check if the list passed as parameter is empty or not. Let us see an example −Examplepublic void my_fun(List<Object> myList){    if (myList == null){       throw new IllegalArgumentException("List is null");    }    if (myList.isEmpty()){       throw new IllegalArgumentException("List is empty");    } ... Read More

Private Methods in Java 9 Interfaces

AmitDiwan
Published on 14-Jul-2020 10:35:58
Following is an example displaying how to use private methods in Java 9 Interfaces −Exampleinterface my_int{    public abstract void multiply_vals(int a, int b);    public default void add_vals(int a, int b){       sub_vals(a, b);       System.out.print("Default method result ");       System.out.println(a + b); ... Read More

Java Program to Print Matrix in Z form

AmitDiwan
Published on 14-Jul-2020 10:33:25
To print matrix in Z form, the Java code is as follows −Example Live Demoimport java.lang.*; import java.io.*; public class Demo{    public static void z_shape(int my_arr[][], int n){       int i = 0, j, k;       for (j = 0; j < n - 1; j++){ ... Read More

Java Program to print distinct permutations of a string

AmitDiwan
Published on 14-Jul-2020 10:31:39
To print distinct permutations of a string, the Java program is as follows −Example Live Demoimport java.util.ArrayList; public class Demo{    static boolean is_present(String my_str, ArrayList<String> rem){       for (String str : rem){          if (str.equals(my_str))          return true;       } ... Read More

Killing threads in Java

AmitDiwan
Published on 14-Jul-2020 10:29:44
Example Live Demopublic class Main{    static volatile boolean exit = false;    public static void main(String[] args){       System.out.println("Starting the main thread");       new Thread(){          public void run(){             System.out.println("Starting the inner thread");         ... Read More

Joiner class Guava Java

AmitDiwan
Published on 14-Jul-2020 10:27:53
Joiner provides various methods to handle joining operations on string, objects, etc. Let us see an example −Exampleimport com.google.common.base.Joiner; import java.util.*; public class Demo{    public static void main(String[] args){       String[] my_arr = { "hel", null, "lo", "wo", "r", null, "ld" };       System.out.println("The original ... Read More

Print Single and Multiple variables in Java

AmitDiwan
Published on 14-Jul-2020 10:26:34
To print single and multiple variables in Java, the code is as follows −Example Live Demopublic class Demo {    public static void main(String args[]){       String name_1 = "Hello";       String name_2 = "World";       System.out.println("Printing single variable");       System.out.printf("%s", name_1);   ... Read More
1 2 3 4 5 6 7 ... 3684 Next
Advertisements