Web Development Articles - Page 510 of 1049

Adding options to a when you press enter with JavaScript?

AmitDiwan
Updated on 14-Jul-2020 17:18:15

332 Views

For this, you need to use keyDown as well as preventDefault(). Following is the JavaScript code −Example Live Demo Document    const pressEnter = (event) => {       if (event.key === "Enter") {          event.preventDefault();       }    };    document.getElementById("disableDefaultTime").addEventListener("keydown",    pressEnter); To run the above program , just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VSCode editor.OutputFollowing is the output. When you press Enter key nothing will be displayed.You need to use keyDown to get time as in the below screenshot −

How to disable future dates in JavaScript Datepicker?

AmitDiwan
Updated on 14-Jul-2020 17:20:31

14K+ Views

In order to disable future dates, you need to use maxDate and set the current date. Following is the JavaScript code −Example Live Demo Document The selected date is as follows:    $(document).ready(function () {       var currentDate = new Date();       $('.disableFuturedate').datepicker({       format: 'dd/mm/yyyy',       autoclose:true,       endDate: "currentDate",       maxDate: currentDate       }).on('changeDate', function (ev) {          $(this).datepicker('hide');       });       $('.disableFuturedate').keyup(function () {     ... Read More

How to identify the nth sub element using xpath?

Debomita Bhattacharjee
Updated on 10-Jun-2020 13:06:19

7K+ Views

We can identify the nth sub element using xpath in the following ways −By adding square brackets with index.By using position () method in xpath.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class SubElement {    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String url = "https://www.tutorialspoint.com/index.htm";       driver.get(url);       driver.manage().window().maximize();       driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);       // xpath using position() targeting the first element with type text       driver.findElement(By.xpath("//input[@type='text'][position()=1]"))     ... Read More

Among id, name, xpath and css, which locator should be used?

Debomita Bhattacharjee
Updated on 10-Jun-2020 13:04:03

394 Views

Each of the locators has some significance. If the page contains uniqueattribute values, we should use them first. However if there are no unique elements, we should use css selector as it is more effective in terms of speed.Css also has a drawback that we cannot traverse from child to parent node which means we cannot travel backward. But xpath allows this feature. Xpath is the most common locator in Selenium and performs traversal through DOM elements and attributes to identify an object.An xpath is represented by two ways namely ‘/ ‘and ‘// ‘. A forward single slash means absolute ... Read More

Difference between ASP and ASP.NET

Nitin Sharma
Updated on 09-Jun-2020 08:29:55

4K+ Views

Both ASP and ASP.NET are the widely used languages for application and mainly the frontEnd development. Both the languages used for dynamic generation of web pages. The content generated through server-side scripting is then sent to the client’s web browser.Following are the important differences between ASP and ASP.NET.Sr. No.KeyASPASP.NET1DefinitionASP or also popularly known as Classic ASP developed by Microsoft is first Server-side scripting engine which is used for dynamic generation of web pages.ASP.NET, on the other hand, is a server-side web framework, open-source, which is designed for the generation of dynamic web pages.2Language typeASP is interpreted language that means the ... Read More

Difference between V-Model and WaterFall Model

Kiran Kumar Panigrahi
Updated on 13-Dec-2022 16:08:56

9K+ Views

Both the Waterfall model and the V-Model are quite widely used development methodologies in the software industry. Both of these models help the development of applications in a systematic way. The basic difference between V-Model and Waterfall model is that, in the V-Model, defects are identified in the testing phase, while in the Waterfall model, defects are identified from the beginning. Read through this article to find out more about the V-Model and the Waterfall Model and how they are different from each other. What is V-Model? V-Model is the development model in which the entire model is ... Read More

Difference Between HTML and ASP.

Nitin Sharma
Updated on 09-Jun-2020 07:56:00

2K+ Views

Both HTML and ASP are the web development languages and are widely used in developing web server pages and applications.On the basis of nature of both of the languages we can distinguish between HTML and ASP as follows −Sr. No.KeyHTMLASP1DefinitionHTML is a client-side language which mainly use for developing user interface.HTML stands for Hypertext MarkUp Language in which "Hypertext" refers to the hyperLinks that an HTML page may contain and "MarkUp language" refers to the way tags are used to define the page layout and elements within the page.On other hand ASP is a server-side language developed by Microsoft i.e., ... Read More

How to redirect to another webpage with JavaScript?

AmitDiwan
Updated on 12-May-2020 13:56:13

2K+ Views

To redirect to another webpage using JavaScript, the code is as follows −Example Live Demo Redirect to a Webpage Example Redirect Click the above button to Redirect to another Webpage    document .querySelector(".redirectBtn") .addEventListener("click", redirectFunction);    function redirectFunction() {       location.href("https://tutorialspoint.com/");    } OutputThe above code will produce the following output −On clicking the “Redirect” button we will be redirected to a new site −

Advertisements