0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

document.getElementByIdが面倒くさいというお話

Last updated at Posted at 2025-05-08

もちろんJavaScriptのお話です。

皆さんは、こう思ったことがあります。

document.getElementByIdって書くのめんどくせぇ…!

そんなあなたに、el関数をあげましょう。

function el(id) {return document.getElementById(id)};
//1行の方が楽だと思う

これを使えば、「どきゅめんとーうんたらかんたら」と書く面倒くささから開放されます!よかったね!

elValue関数

皆さんは、こうも思ったことがあります。

いやわかったけどさ、el(id).valueって書くのすらめんどくせぇ…!

そんなあなたに、elValue関数をあげましょう。

function elValue(id) {return el(id).value};
// el関数も併用できればめっちゃ短く終わる

これを使えば、「えるばりゅーうんたらかんたら」と書く面倒くささから開放されます!よかったね!


それだけです。

終わりに

みんなもこの2つの関数を使って良いプログラマーライフを!

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?