Why is the page updated when pressed on the search button?



  • * {box-sizing: border-box;}
    form {
      position: relative;
      width: 750;
      margin: 25px;
    }
    input {
      width: 100%;
      height: 42px;
      padding-left: 10px;
      border: 2px solid silver;
      border-radius: 5px;
      outline: none;
      background: #F9F0DA;
      color: #9E9C9C;
    }
    button {
      position: absolute; 
      top: 0;
      right: 0px;
      width: 42px;
      height: 42px;
      border: none;
      background: silver;
      border-radius: 0 5px 5px 0;
      cursor: pointer;
    }
    button:before {
      content: "\f002";
      font-family: FontAwesome;
      font-size: 16px;
      color: #F9F0DA;
    }
        
    <form>
                <input type="text" placeholder="Искать здесь...">
                <button type="submit"></button>
            </form>



  • button type="submit" - means when she's on the click, all the data from the form will be sent to the server. Request is always sent to the address indicated in the attribution action♪ If there's no such attribute or it's empty. action=''the form will be sent to the same url on which it is located. So the page is just being updated.


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2