Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to alert inline of button

Tags:

javascript

I know already how to alert by use javascript or Jquery. But just onclick button I apply javascript external or internal. What I need is we alert inline of button Example:

<button name="my_btn" id="my_btn" onClick="alert('Hello I am alert')">Alert</button>

If it is possible please tell me. I am waiting for all of you

like image 692
Bong Yuth Avatar asked Aug 20 '13 08:08

Bong Yuth


People also ask

How to add alert message on button click in HTML?

If you want the ability to close the alert message, add a <span> element with an onclick attribute that says "when you click on me, hide my parent element" - which is the container <div> (class="alert"). Tip: Use the HTML entity " &times; " to create the letter "x".

How to give alert msg in HTML?

The Window alert() method is used to display an alert box. It displays a specified message along with an OK button and is generally used to make sure that the information comes through the user. It returns a string which represents the text to display in the alert box.

What is alert () in JavaScript?

The alert() method displays an alert box with a message and an OK button. The alert() method is used when you want information to come through to the user.

How do you add an alert to a script?

The alert() method in JavaScript is used to display a virtual alert box. It is mostly used to give a warning message to the users. It displays an alert dialog box that consists of some specified message (which is optional) and an OK button. When the dialog box pops up, we have to click "OK" to proceed.


2 Answers

I never really understand why someone wants to do it this way, but here is an inline alert on a button.

<button type="button" onclick="alert('Hello World')">Show Alert</button>

Here is the fiddle

By the way, I believe this question has been answered

Did I answer your question?

like image 131
j7my3 Avatar answered Sep 26 '22 12:09

j7my3


<input type='button' onclick="javascript:alert('test');" value='Button'/>
like image 42
usman allam Avatar answered Sep 23 '22 12:09

usman allam