Question about brackets ><

Question about brackets ><
0

#1

Hey guys. Could anyone explain to me the reason behind placing ‘$(document).ready(function(){});’ outside of the <- this one has closed instantly with the function following. Could anyone explain this to me? "

Your code so far



<!-- Only change code above this line. -->

<div class="container-fluid">
  <h3 class="text-primary text-center">jQuery Playground</h3>
  <div class="row">
    <div class="col-xs-6">
      <h4>#left-well</h4>
      <div class="well" id="left-well">
        <button class="btn btn-default target" id="target1">#target1</button>
        <button class="btn btn-default target" id="target2">#target2</button>
        <button class="btn btn-default target" id="target3">#target3</button>
      </div>
    </div>
    <div class="col-xs-6">
      <h4>#right-well</h4>
      <div class="well" id="right-well">
        <button class="btn btn-default target" id="target4">#target4</button>
        <button class="btn btn-default target" id="target5">#target5</button>
        <button class="btn btn-default target" id="target6">#target6</button>
      </div>
    </div>
  </div>
</div>

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36.

Link to the challenge:


#2

Outside of the what??


#3

@Numbtea,
the reason this exercise tells you to place the JQuery code above the HTML markup is because of the fact that the JQuery code has no business inside the HTML markup. You cannot add that code anywhere inside the HTML markup unless you put it inside a script element.


#4

Sorry, it was late when i made the post, i’ll clear up what i was trying to ask.
On the solution to this question the “$(document).ready(function(){});” sits on the left of the first closing bracket.
Up to this point when I’ve been making classes for div, h3 etc they always sit before the first closing bracket.
<h* class=“some-class”> Like this.
In this instance its angle bracket “script” close angle bracket "function-text"
I’m just curious as to why with the document ready function it sits after the first closed angle bracket.
Hopefully that explains it a little clearer?

Ps. I keep trying to write out what I want but because its Html it vanishes after I hit save edit… is there a way I can isolate areas of code for you guys to read more clearly with it dissapearing?


#5

To enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.