Guest User

Untitled

a guest
May 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <script>
  2. $(document).ready(function(){
  3. $('#myInputElement').bind('change', function(){
  4. //var oldvalue = ???
  5. var newvalue = $(this).val();
  6. });
  7. });
  8. </script>
  9. <input id="myInputElement" type="text">
  10.  
  11. <script>
  12. //look no global needed:)
  13.  
  14. $(document).ready(function(){
  15. // Get the initial value
  16. var $el = $('#myInputElement');
  17. $el.data('oldVal', $el.val() );
  18.  
  19.  
  20. $el.change(function(){
  21. //store new value
  22. var $this = $(this);
  23. var newValue = $this.data('newVal', $this.val());
  24. })
  25. .focus(function(){
  26. // Get the value when input gains focus
  27. var oldValue = $(this).data('oldVal');
  28. });
  29. });
  30. </script>
  31. <input id="myInputElement" type="text">
  32.  
  33. <script>
  34. $(document).ready(function(){
  35. $('#myInputElement').bind('change', function(){
  36. var newvalue = $(this).val();
  37. });
  38. $('#myInputElement').blur(function(){
  39. $('#myHiddenInput').val($(this).val());
  40. });
  41. });
  42. </script>
  43. <input id="myInputElement" type="text">
  44.  
  45. <script>
  46. $(document).ready(function(){
  47.  
  48. var newValue = $('#myInputElement').val();
  49. var oldValue;
  50.  
  51. $('#myInputElement').change(function(){
  52. oldValue = newValue;
  53. newValue = $(this).val();
  54. });
  55. });
  56. </script>
  57. <input id="myInputElement" type="text">
  58.  
  59. // regular
  60. $(elem).data(key,value);
  61. // 10x faster
  62. $.data(elem,key,value);
  63.  
  64. $('#myInputElement').change(function(event){
  65. var defaultValue = event.target.defaultValue;
  66. var newValue = event.target.value;
  67. });
  68.  
  69. $(document).ready(function() {
  70. $("input[type=text]").change(function() {
  71. $(this).data("old", $(this).data("new") || "");
  72. $(this).data("new", $(this).val());
  73. console.log($(this).data("old"));
  74. console.log($(this).data("new"));
  75. });
  76. });
Add Comment
Please, Sign In to add comment