2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jQueryで input, select, textarea を判定する

Posted at

やり方


$(":input").each(function() {
    var $this = $(this);
    if ($this.is("input")) {
        // <input> element.
    } else if ($this.is("select")) {
        // <select> element.
    } else if ($this.is("textarea")) {
        // <textarea> element.
    }
});

参照

forms - determining input vs textarea in jQuery - Stack Overflow https://stackoverflow.com/questions/8300584/determining-input-vs-textarea-in-jquery

めも

textareaか???の判断をしたかったときに、 attr('type') で属性が取得できなかった。
よく考えれば、textareatypeなどない。どうやって判定するのかちょっと躓いたので、めもった。

2
2
0

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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?