Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Test Page</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
  body {
    font-family: sans-serif;
  }
  p {
    margin: 0px;
  }
</style>
</head>
<body>
  <input type="number" min="0" maxlenght="3" class="form-control product-quantity"  id="1-qty" name="qty[1]" value="" />
  <input type="hidden" id="1-key"  value="2">
  <form id='theForm'>
    <select class="test" id='foo'>
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
    </select>
    <select class="test" id='bar'>
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
    </select>
</body>
</html>
 
jQuery(function() {
  
  $(".product-quantity").change(function(event) {
    var id=(event.target.id).substr(0,1);
    alert(id);
    display("Changed: " + event.target.value);
    display("Key :"+$('#'+id+"-key").val());
  });
  
  function display(msg) {
    $("<div>").html(msg).appendTo(document.body);
  }
  
});
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers