Button Click JQuery does not work -
i'm having troubles button click in jquery. have post values of input fields via ajax button click self doesn't work.
when log console doesn't register button click.
can guys me out please?
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>ajax calls servlet using javascript , json</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> </head> <body> <h1>tasks do</h1> <form method="post"> <input type="text" placeholder="give task's name" name="name" id="name" /> <input type="text" placeholder="give task's summary" name="summary" id="summary" /> <input type="button" id="submit" value="submit" class="submit"/> </form> <br/> <h1>here open tasks 2</h1> <div id="open"></div> <script> $(document).ready(function() { $(".submit").click(function(){ $("#open").html = "button clicked"; }); }); </script> </body> </html>
your syntax not correct change .html =
.html(htmlcode)
. read documentation of html()
method in jquery better understanding
$(document).ready(function() { $(".submit").click(function() { $("#open").html("button clicked"); // -----^----- }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <h1>tasks do</h1> <form method="post"> <input type="text" placeholder="give task's name" name="name" id="name" /> <input type="text" placeholder="give task's summary" name="summary" id="summary" /> <input type="button" id="submit" value="submit" class="submit" /> </form> <br/> <h1>here open tasks 2</h1> <div id="open"></div>
or can use innerhtml
$(document).ready(function() { $(".submit").click(function() { $("#open")[0].innerhtml = "button clicked"; }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <h1>tasks do</h1> <form method="post"> <input type="text" placeholder="give task's name" name="name" id="name" /> <input type="text" placeholder="give task's summary" name="summary" id="summary" /> <input type="button" id="submit" value="submit" class="submit" /> </form> <br/> <h1>here open tasks 2</h1> <div id="open"></div>
Comments
Post a Comment