Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Notify.js with button?

Ive downloaded Notify.js'files and put them in root of webpage. im trying to test it but i didn't get anything when click on button

<html>

<head>
<title>Untitled</title>
<script src="notify.js"></script>
</head>

<body>
<input name="notif" type="button" value="Shoow notif" onclick="$(".elem-demo").notify("Hello Box");">
</body>

</html>

Whats the problem?

like image 907
Edd Hakobyan Avatar asked Dec 11 '25 01:12

Edd Hakobyan


1 Answers

This is your answer and working:

<html>
<head>
<title>Untitled</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="notify.js"></script>
</head>

<body>
<input name="notif" type="button" value="Shoow notif" onclick="$('.elem-demo').notify('Hello Box');"/>

<div class="elem-demo">a Box</div>
</body>

</html>

1-You forgot to include jquery to your file.

2-You should create an element that has a elem-demo class

3-Your javascript had a problem! You can't use double-quotation and it's child has double-quotation too.

here is your code example, and then my code:

onclick="$(".elem-demo").notify("Hello Box");"  //Your code

onclick="$('.elem-demo').notify('Hello Box');"  //My code
like image 166
Mohammad Kermani Avatar answered Dec 13 '25 17:12

Mohammad Kermani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!