Onclick alert input text..

In this tutorial , we will try to create a code in HTML and JavaScript. One Html button , and a Html input text. When the user writes some text in the input and click on the button. A JavaScript alert will show the value of the input text .

First we will start by creating a button and an input text :

<input type="text"  id="text_id" placeholder="sometext.."> 

<button type="button" onclick="showText()">show Text</button>

Then we will create a JavaScript function showText() . this function will be executed when we click on the button :

function showText() {

Now try to write some text in the input . when we click on the button , we will see the text in one JavaScript Alert.

Also read , how to insert an HTML element before another in JavaScript ?



  1. Pingback: (SOLVED) How to open a URL in a new Tab ? » JavaTuto

Laisser un commentaire