Junior
Junior

Reputation: 11990

How to find all inputs inside of a div that are not of a type "hidden" using jQuery?

I am trying to get all inputs that are inside on a div. The inputs cannot be hidden type.

Here is what I have done

  $("#MasterContentViewer :input:not([type=hidden])").each(function(e){

            var input = $(this);

            var name = input.attr('name').toLowerCase();

            var tag = $('meta[name="is_attr_' + name + '"]');

            if( tag.length ){

                tag.val( input.val() );

            }

        });

That gives me an error in toLowerCase as it is not a valid property of null

How can I correctly find all inputs inside my MasterContentViewer div with a type not hidden?

Upvotes: 1

Views: 46

Answers (1)

The Process
The Process

Reputation: 5953

Like this:

$("#MasterContentViewer input:not(:hidden)").each(function(e){

        var input = $(this);

        var name = input.attr('name').toLowerCase();

        var tag = $('meta[name="is_attr_' + name + '"]');

        if( tag.length ){

            tag.val( input.val() );

        }

    });

Upvotes: 2

Related Questions