script on head or /body??

Discussion in 'jQuery' started by piropeator, Jun 20, 2016.

  1. #1
    I have this code:
    <!doctype html>
    <html lang="es">
    <head>
      <meta charset="utf-8">
      <title>Test </title>
      <link rel="stylesheet" href="css/jquery-ui.min.css">
      <link rel="stylesheet" href="css/bootstrap.min.css">
    
      <script src="js/jquery.js"></script>
      <script src="js/jquery-ui.min.js"></script>
      <script src="js/bootstrap.min.js"></script>
     
      <script>
        $(function() {
          $( "#datepicker" ).datepicker();
        });
      </script>
    </head>
    
    <body>
    
    <p>Date: <input type="text" id="datepicker"></p>
      <h1>Hola</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam, possimus veniam porro maxime, ipsam quia dolores omnis mollitia quasi illum dolor eos veritatis cumque incidunt delectus vel consequuntur nesciunt aliquid.
      </p>
      <button class="btn btn-primary">Botón</button>
    
    </body>
    </html>
    HTML:
    It works, but before the scripts bootstrap and jquery was in body. But when I insert jquery-ui.js doesnt work in body but it works in head.
    Is correct this setting?
     
    piropeator, Jun 20, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    If jQuery ui doesn't work before /body you're doing something wrong. I'm guessing (no, I'm not guessing, I know) that it's because you're not actually declaring document ready before calling datepicker.
    Besides, the code for the page is gibberish (you have an input without a form, wrapped in a p-element. You're also using bootstrap: why?
     
    PoPSiCLe, Jun 20, 2016 IP
  3. piropeator

    piropeator Well-Known Member

    Messages:
    194
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    121
    #3
    Well this code is a example, for that not has a form, I am going to use bootstrap for that is there.
    And my mistake was the wrong release from jquery.
    :)
     
    piropeator, Jun 21, 2016 IP