How do I use Notify.js with a button?

I downloaded Notify.js'files and put them in the root page. i try to test it but i got nothing on button click

<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>

      

What is the problem?

+3


source to share


1 answer


This is your answer and work:

<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 in your file.

2-You must create an element with class elem-demo



3-Your javascript has a problem! You cannot use double quote and it has double quote as well.

here is your example code and then my code:

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

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

      

+5


source







All Articles