$ (function () does not work

-1

I'm a beginner in this language and I have the following question:  the code below is working, however if I take the comment from the part * This block does not work * , it does not work, but I need it to activate a calendar in another source that I have. Is there any way it can work without the block exiting the body and the datepicker script remains in the head?

<!DOCTYPE html>
<html>
<head>
    <meta content="text/html">
    <meta charset= "UTF-8" http-equiv="content-type">
    <title>Consulta de Apartamento</title>
    <link rel="stylesheet" href="css/estilos_gerais.css" type="text/css">
    <link rel="stylesheet" href="css/retorno_consulta.css" type="text/css">
    <script src="http://code.jquery.com/jquery-2.2.3.min.js"></script><scriptsrc="http://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>      
    <script src="http://code.jquery.com/jquery-migrate-1.4.0.min.js"></script><linkrel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css"> 
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script><!--***Comestebloconãofunciona***<scripttype="text/javascript">      
        $(function() {$( ".data" ).datepicker({
            showOn: "button",
            buttonImage: none,
            buttonImageOnly: true,
            changeMonth: true,
            changerYear: true,
            showOtherMonths: true,
            selectOtherMonths: true,
            dateFormat:  'dd/mm/yy',
            dayNames:['Domingo','segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
            dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
            dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab','Dom',],
            monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto',
            'Setembro','Outubro','Novembro','Dezembro',],
            monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez']});});
      </script> -->
</head>
<body>

 <script type="text/javascript">
$(document).ready(function () {
$("#btnTestar").click(function(){
      alert("Hello, World.");
    });
});
  </script>
<form>
  <button id="btnTestar">Testar</button>
</form>
</body>
</html>
    
asked by anonymous 31.03.2018 / 05:32

2 answers

1

Have you noticed that you are loading versions 2.2.3 and 1.10.1 of jQuery?

<script src="http://code.jquery.com/jquery-2.2.3.min.js"></script><scripttype="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

Removing loading from version 1.10.1 the code seems to work, at least the alert window appears and the console stops giving error.

Ah, I think it's null instead of none in buttonImage .

    
31.03.2018 / 06:07
1

First point: You are using a jQuery UI pluguin that would be another library on which depends on jQuery to work.

Check the compatibility of the jQueryUI version with that of jQuery.

As already mentioned, you use 2 versions of jquery simultaneously, decide which one would be the best suited, or more compatible with the rest of the code.

Make sure the datepicker code is actually working, because no matter where it is instantiated, in the header or inside the script outside the header, it should work.

If everything goes wrong, start from scratch: Go to the jquery UI website to download the stable version. Take an example of using datepicker and apply it to the page.

Try to organize better how scripts are loaded, jQuery always first in relation to other scripts. Your css always last to external ones.

The datepicker code depends on an element that I believe to be an Input with the date class in order to work, so be sure that this is not going to work.

Reference: link

    
31.03.2018 / 14:47