Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(document).ready(function(){
- $('#myInputElement').bind('change', function(){
- //var oldvalue = ???
- var newvalue = $(this).val();
- });
- });
- </script>
- <input id="myInputElement" type="text">
- <script>
- //look no global needed:)
- $(document).ready(function(){
- // Get the initial value
- var $el = $('#myInputElement');
- $el.data('oldVal', $el.val() );
- $el.change(function(){
- //store new value
- var $this = $(this);
- var newValue = $this.data('newVal', $this.val());
- })
- .focus(function(){
- // Get the value when input gains focus
- var oldValue = $(this).data('oldVal');
- });
- });
- </script>
- <input id="myInputElement" type="text">
- <script>
- $(document).ready(function(){
- $('#myInputElement').bind('change', function(){
- var newvalue = $(this).val();
- });
- $('#myInputElement').blur(function(){
- $('#myHiddenInput').val($(this).val());
- });
- });
- </script>
- <input id="myInputElement" type="text">
- <script>
- $(document).ready(function(){
- var newValue = $('#myInputElement').val();
- var oldValue;
- $('#myInputElement').change(function(){
- oldValue = newValue;
- newValue = $(this).val();
- });
- });
- </script>
- <input id="myInputElement" type="text">
- // regular
- $(elem).data(key,value);
- // 10x faster
- $.data(elem,key,value);
- $('#myInputElement').change(function(event){
- var defaultValue = event.target.defaultValue;
- var newValue = event.target.value;
- });
- $(document).ready(function() {
- $("input[type=text]").change(function() {
- $(this).data("old", $(this).data("new") || "");
- $(this).data("new", $(this).val());
- console.log($(this).data("old"));
- console.log($(this).data("new"));
- });
- });
Add Comment
Please, Sign In to add comment