enter image description here

<a id="test"></a> <script> var test = $('#test'); console.log(test); console.log(test[0]); </script> 

I request the contents of the test selector twice, in the second case with the index 0. In the picture that issued the console. What is this "phenomenon" called - you can get the html-format only by assigning an index (or is it not an index?), And what is the presentation in the first case?

    1 answer 1

    In the case of a jquery object, you can work with it using the methods of the jquery library, for example, $('#test').offset().top .
    In the second case, this is a native js , which could be obtained as document.querySelector('#test') , you can also work with this object, but using native js methods, for example document.querySelector('#test').getBoundingClientRect()

    Also, these objects can be converted to each other, for example:

     var js, jq; jq = $('#test'); js = jq[0]; js = jq.get(0); js = document.getQuerySelector('#test'); jq = $(js); 
    • And where you can read about this conversion here js = jq [0]; js = jq.get (0); I do not find it in Google, so that serious sources ... I would study this topic thoroughly. - Natasha
    • one
      Well, this is not something that is straightforward conversion and it is necessary once every five years. This is essentially just the extraction of a native js element from a jquery object. The method is described in the official documentation api.jquery.com/get - sepgg