jQuery(#id).val() vs. getElementById(#id).value

前端 未结 7 944
眼角桃花
眼角桃花 2020-12-01 16:02

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

7条回答
  •  被撕碎了的回忆
    2020-12-01 16:14

    I think using pure Javascript is quicker for the following reasons:

    1. You won't have to learn more than pure js
    2. If you don't want errors, use catch(exeption) (I think...)
    3. You don't have to put in that little extra time to type in the code to initiate jquery
    4. The browser responds quicker if you don't use jquery
    5. Normal js works (in a better way) on checkboxes @johndodo

    Thank you for listening to my answer.

提交回复
热议问题