mercredi 5 juin 2019

Get Tag from id => javascript/jquery

I am curious if it is possible to get tag equivalent to jquery's $('tag_name') by just having an id at hand? For example:


    var some_id = document.getElementById('my_Id');
    //and then do something like
    var get_tag = some_id.its_tag;

Is something like this possible?

I know we can get all tags into one place, like list, and then loop through that list and check each id, but curious if there is something that can be done elegantly?

Thanks!

Alternative is known, but would be great if original question actually has some answer too.


    var some_id = document.getElementById('my_Id');
    //and then do something like
    var get_tag = some_id.its_tag;




Aucun commentaire:

Enregistrer un commentaire