Using the .replaceWith() function

Using the .replaceWith() function

Hey Guys. I am a little bit confused how this works. In the script below its replacing
  1. div.second with <h2>New heading</h2>

What I don't understand is why is it using the selector as div.second ?? When the div class is called "inner second"? Thanks for your help in advance...


  1. <div class="container">
    <div class="inner first">Hello</div>
    <div class="inner second">And</div>
    <div class="inner third">Goodbye</div>
    </div>
           





  1. $( "div.second" ).replaceWith( "<h2>New heading</h2>" );