【发布时间】:2013-12-29 15:35:30
【问题描述】:
如何在 index.php 中插入 javascript 插件?
我尝试包含typeahead.js,但没有成功。
我需要包含整个文件夹还是应该只包含 typeahead.js 文件?
javascript 插件链接:http://plugins.jquery.com/typeahead.js/
这是我当前的 index.php 代码:
<?php
include 'script_suggestion.php';
include 'script_close_suggestion_box.php';
?>
<html>
<head>
<title>
Brandon's Search Engine
</title>
<style type="text/css">
#suggestion {
border: 1px solid black;
visibility: hidden;
position: relative;
background-color: white;
z-index: 10;
}
#suggestion a {
font-size: 12pt;
color: black;
text-decoration: none;
display: block;
width: 648px;
height: auto;
text-align: left;
padding: 2px;
}
#suggestion a:hover {
background-color: #dddddd;
width: 644px;
padding: 2px;
}
</style>
</head>
<body>
<form method="GET" action="search.php" name="q">
<table align="center">
<tr>
<td>
<h1><center>Brandon's Search Engine</center></h1>
</td>
</tr>
<tr>
<td align="center">
<input type="text" name="q" id="q" style="height: 27px; width: 650px; padding: 2px" placeholder="Search Now"
onkeyup="getSuggestion(this.value)" autocomplete="off" onblur="closeBox()"/>
<script>document.getElementById('q').focus()</script>
<div id="suggestion" style="width: 648px">
</div>
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="Search" style="height: auto; width: 60px; padding: 2px" />
<input type="reset" value="Clear" onclick="closeBox()" style="height: auto; width: 50px; padding: 2px" />
</td>
</tr>
<tr>
<td align="center">
Can't find your site? <br /> Insert <a href="insert.php">here</a>.
</td>
</tr>
</table>
<input type="hidden" name="page" value="1" />
</form>
</body>
</html>
提前致谢。
【问题讨论】:
-
您是否单击了“阅读文档”链接?它详细说明了如何使用它。您需要在页面上包含一些基本的 JS。
-
script_suggestion.php的内容是什么?是否包含 jQuery 库? -
你看到文档了吗:github.com/twitter/typeahead.js
-
@AwladLiton 他使用的是 jQuery 插件,而不是 Twitter 的 TypeHead...plugins.jquery.com/typeahead.js
-
我不确定我是否包含,
script_suggestion.php的链接:link
标签: javascript php jquery jquery-plugins