How to select all textareas and textboxes using jQuery?

后端 未结 5 2056
有刺的猬
有刺的猬 2020-12-02 15:03

How can I select all textboxes and textareas, e.g:


and


         


        
5条回答
  •  独厮守ぢ
    2020-12-02 16:02

    names = [];
    $('input[name=text], textarea').each(
        function(index){  
            var input = $(this);
            names.push( input.attr('name') );
            //input.attr('id');
        }
    );
    

    it select all textboxes and textarea in your DOM, where $.each function iterates to provide name of ecah element.

提交回复
热议问题