gpt4 book ai didi

javascript - 即使包含 timepicker css 和 js 文件,$(...).timepicker 也不是函数错误?

转载 作者:行者123 更新时间:2023-12-03 04:24:20 26 4
gpt4 key购买 nike

出于某种原因,我收到错误 $(...).timepicker is not a function 即使我在脑海中包含了 timpicker css 和 js 文件。它之前工作正常,所以我不确定我做了什么把它弄乱了。请提供任何帮助,我们将不胜感激!

代码

config.php

<?php session_start();?>
<!DOCTYPE html>
<html>
<head>
<!--Main stylesheets-->
<link rel="stylesheet" type ="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/form.css">
<link rel="stylesheet" type="text/css" href="css/login.css">
<!--Custom icon-->
<link href="https://file.myfontastic.com/uZM4xs3mM5re5dydBReL44/icons.css" rel="stylesheet">
<!--Import jQuery -->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<!-- jQuery timepicker -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.8.1/jquery.timepicker.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>
<!--Javascript-->
<script type="text/javascript" src="js/main.js"></script>

events.php

<?php include 'config.php'; ?>
<link rel="stylesheet" type="text/css" href="css/events.css">
<!-- jQuery library for datepicker -->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<title>For Sale</title>
</head>
<body>
<header>
<h1>Events</h1>
<?php
if(isset($_SESSION['logged_user'])) {
echo "<button class='add-event'><span class='icon-plus'></span></button>";
}
?>
</header>
<div class="events">
<?php
include 'nav.php';
include 'php/login.php';
include 'php/logout.php';
include 'php/event-form.php';
?>
</body>
</html>

event-form.php

<div class="event-form form-screen pop-up">
<button class="close-pop-up"><span class="icon-x"></span></button>
<form name="event-form" method="post">
<h1>Create Event</h1>
<div class="form-content">
<div class="box">
<input type="file" name="file" id="file" class="inputfile" data-multiple-caption="{count} files selected" multiple />
<label for="file">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17">
<path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z" /> </svg> <span>Choose a file&hellip;</span> </label>
</div>
<input type="text" name="title" placeholder="Title*" required>
<input type="text" name="start_date" class="date" placeholder="Start Date*" required>
<input type="text" name="start_time" class="timepicker" placeholder="Start Time*" required>
<h1 class="time-label">to</h1>
<input type="text" name="end_date" class="date" placeholder="End Date">
<input type="text" name="end_time" class="timepicker" placeholder="End Time">
<input type="text" name="place" placeholder="Place">
<input type="text" name="description" placeholder="Description">
</div>
<button type="submit" class="submit" name="submit" value="submit">Add Event</button>
</form>
</div>

ma​​in.js

$(document).ready(function () {
//Timepicker
$('input.timepicker').timepicker({
timeFormat: 'h:mm p',
interval: 30,
minTime: '8:00am',
maxTime: '11:00pm',
// defaultTime: '5:00pm',
startTime: '8:00am',
dynamic: true,
dropdown: true,
scrollbar: true,
showLeadingZero: false
});
});

最佳答案

在 events.php 中,您将包含 JQuery 和 JQuery UI,即使您已经将其包含在 config.php 中。多次包含 JQuery 会导致很多问题;尝试从 events.php 或 config.php 中删除以下行

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

关于javascript - 即使包含 timepicker css 和 js 文件,$(...).timepicker 也不是函数错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43809070/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com