I have a laravel project with create.blade.php file:
<input id="testButton" type="submit" value="test"/>
and a javascript api.js file:
$(document).ready(function() {
$("testButton").click(function(){
alert("button pressed"):
});
});
How do i make a button from HTML execute the JS code?
So far i have tried replacing JS code with this:
$("testButton").click(function(){
alert("button pressed");
});
or this:
$(document).on("click","testButton",function(){
alert("button pressed");
});
but it did nothing.
Replacing <input>
to <button>
and changing type=
from submit
to button
also did nothing.