0

when I remove javascript my reset button works fine but when I load JavaScript its stops working.I have also tried making rest button using jQuery function. I have also tried using input type="reset" value="Reset" but it is also not working. I have tried every thing that I know now I do not know what to do.

Please help

$(document).ready(function c () {
  $("#f").click(function(event){
    $("body").toggleClass("hi");
    event.preventDefault();
  });			
});

$(document).ready(function c1() {
  $("body").click(function(event){
    $("p").toggleClass("hii");
    event.preventDefault();
  });			
});   

//reset funtion using jquery
/*$(document).ready(function re(){
  $("form").click(function(event){
    $("#r").reset(); //reset funtion using jquery
  });	
})*/
body{
  font-size: x-large;
}
h2{
  color: blue;
}
body.hi{
  background:#242424;
  color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div align="right"><input type="submit" id="f" name="night mode" value="night mode" onclick="c()" onclick="c1()"></div>
<h2>contact form</h2>
<form action="mailto:[email protected]" method="post" enctype="text/plain">
  <label  for="company">company's name<br>
    <input type="text" id="company" name="company" autocomplete="companyname" placeholder="name" >
  </label><br>
  <label for="contact_person">contact person<br>
    <input type="text" id="contact_person" name="contact person" autocomplete="contact person" placeholder="name">
  </label><br>
  <label for="email">email <br>
    <input type="email" id="email" autocomplete="email" name="email" placeholder="[email protected]"> <br>
  <label >Subject</label>
  <br>
  <textarea  name="subject" placeholder="Write something.."></textarea><br>
  <button type="submit" value="Submit">Submit</button> reset button 
    I have also tried using input type="reset" value="Reset"
                but it is also not working 
  <button type="reset"  onclick="re()" id="r">Reset</button>
</form>

1
  • reset funtion using jquery - possibly this syntax error is screwing with you Commented Oct 30, 2017 at 4:17

1 Answer 1

4

Your problem is that you are writing your $(document).ready() wrong. You do not declare a callable function as a parameter name to ready(). It should look like this:

$(document).ready(function() {
    function myFunc(event) {
        console.log("Function MyFunc() called");
    }
});

Next you should only have one $(document).ready(). JavaScript does support multiple ready() declarations, but this just clutters up your code.

$( document ).ready()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.