I been searching but I can only find articles talking about one or the other. Which one is better?
I\'m making a small web app where performance is not a big concern
I've been looking into the performance differences with this recently and, slightly unsurprisingly, using vanilla JS to grab a value is faster than using jQuery. However, the fallbacks that jQuery provides to prevent errors, like what @Matt mentioned, is very useful. Therefore, I tend to opt for the best of both worlds.
var $this = $(this),
$val = this.value || $this.val();
With that conditional statement, if this.value
tries to throw an error, the code falls back to the jQuery .val()
method.