How to know the type of the DOM object

1

I'd like to know if I'm using JS or Jquery, there's a way I can identify the kind of DOM object I'm manipulating.

For example, I make the following selector: $('#filtos select, #filtos input').each(function (index, obj).....);

Inside this each I will have objects <select> , <input> of type text , checkbox among others. I would like to know if you have any properties that tell me the type of these elements.

    
asked by anonymous 15.06.2016 / 17:15

1 answer

1

Use something like this:

$('#filtos select, #filtos input').each(function (index, obj) {
    var $this = $(obj)

    var meu_elemento = $this[0].tagName;

     if (meu_elemento == 'input') {
          var meu_tipo = $this.attr('type');
     }        
});

link

    
15.06.2016 / 19:48