/ / jQuery Datepicker non risponde [chiuso] - javascript, jquery, jquery-ui, datepicker

jQuery Datepicker non risponde [chiuso] - javascript, jquery, jquery-ui, datepicker

sto usando questo semplicissimo codice datepicker dai documenti dell'interfaccia utente jQuery ma non funziona sul mio Mac:

<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>

<body>
<input type="text" id="date-picker" />
<script>
$("#date-picker").datepicker();
</script>
</body>

Qualcuno può dirmi perché non funziona? Grazie in anticipo!

risposte:

2 per risposta № 1

L'interfaccia utente di jQuery dipende da jQuery.

Pertanto è necessario includere lo script jQuery prima dello script dell'interfaccia utente jQuery:

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="https://code.jquery.com/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>

Non è necessario includere jQuery due volte. Quanto sopra sarà sufficiente.

Ecco un esempio di lavoro.


1 per risposta № 2

Dovresti aggiungere jquery prima di aggiungere jqueryui.
Hai aggiunto due volte jquery. Rimuovi uno

<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<!--    <script type="text/javascript" src="https://code.jquery.com/jquery.min.js"></script>-->


<body>
<input type="text" id="date-picker" />
<script>
$("#date-picker").datepicker();
</script>
</body>

1 per risposta № 3

yeahh include jquery prima di jquery ui

<!doctype html>
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
</head>

<body>
<input type="text" id="date-picker" />
<script>
$("#date-picker").datepicker();
</script>
</body>