title: Modifying Jquery's val() method but not working properly
body: <p>So i tried to modified the original jQuery's val() method using the following code</p>
  
  <pre><code>(function ($) {
      var original_val = jQuery.fn.val;
      jQuery.fn.val = function( value ) {
          var elem = this[0], val = undefined;
  
          // Set for value first, if its undefined
          val = value ? value : "";
  
          if (elem){
              if (elem.hasAttribute('thisattribute')){
                  if (val){
                      if (typeof val === 'number'){
                          // Do something here if val is a typeof number
                      }
                  } else {
                      // Do something here if val doesn't exist
                  }
              }
          }
  
          console.log("Let me see what is value ::: ", val);
          console.log("Let me see what is elem ::: ", elem);
  
          return original_val.apply(this, [val]);
      }
  })(jQuery);
  </code></pre>
  
  <p>Using the code above, i check if the input element has a certain attribute on it, then proceed with modifying the value, before passing it to the original jQuery's val() method.</p>
  
  <p>Using this method i managed to modify the value when i use the following code</p>
  
  <pre><code>$(id).val(10000)
  </code></pre>
  
  <p>But when i tried to retrieve the value using bottom code, it failed</p>
  
  <pre><code>$(id).val()
  </code></pre>
  
  <p>Some more, i can no longer chain the val() method with other method like trim() after i modified it, as it throws me the following error</p>
  
  <pre><code>Uncaught TypeError: input.val(...).trim is not a function
  </code></pre>
  
  <p>What did i do wrong here?</p>