Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>JS Bin</title>
  </head>
  <body>
   
    <div>
      <label>Name:</label>
      <input id="name" type="input" />
    </div>
    <div>
      <label>Comment:</label>
      <input id="comment" type="input" />
    </div>
    <div>
      <label>City:</label>
      <select id="city">
        <option>London</option>
        <option>Paris</option>
        <option>New York</option>
      </select>
    </div>
      
    <button id="getName">Get Name</button>
    <button id="getComment">Get Comment</button>
    <button id="getCity">Get City</button>
    
    <script src="https://code.jquery.com/jquery-2.0.3.js"></script>
  </body>
</html>
 
$(() => {
 
  $("#getName").click(() => {
    // read value of text field
    const name = $("#name").val()
    alert(name)
  })
  
  
  $("#getComment").click(() => {
    // read value of the text area
    const comment = $("#comment").val()
    alert(comment)
  })
  
  
  $("#getCity").click(() => {
    // read value from select dropdown
    const city = $("#city").val()
    alert(city)
  })
})
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x