如何将 jQuery 插件插入 PHP 代码?
我想插入 jQuery 插件下拉登录表单 让我的网站更漂亮,但我真的很困惑在哪里以及如何将 jQuery 插入到我的代码中。例如,以下是我的 index.php
:
<?php
include ('book_fns.php');
session_start();
do_html_header("Welcome to Store");
echo "<p>Please choose a category:</p>";
// Get categories out of database
$cat_array = get_categories();
// Display as links to cat pages
display_categories($cat_array);
//If logged in as admin, show add, delete, edit cat links.
if(isset($_SESSION['admin_user'])) {
display_button("admin.php", "admin-menu", "Admin Menu");
}
do_html_footer();
?>
我想将 jQuery 插件添加到我的索引页面的顶部。
我如何插入这个 jQuery 插件?
I want to insert the jQuery plugin dropdown login form to make my website more pretty, but I am really confused where and how to insert jQuery into my code. For instance the following is my index.php
:
<?php
include ('book_fns.php');
session_start();
do_html_header("Welcome to Store");
echo "<p>Please choose a category:</p>";
// Get categories out of database
$cat_array = get_categories();
// Display as links to cat pages
display_categories($cat_array);
//If logged in as admin, show add, delete, edit cat links.
if(isset($_SESSION['admin_user'])) {
display_button("admin.php", "admin-menu", "Admin Menu");
}
do_html_footer();
?>
And I want to add the jQuery plugin to the top of my index page.
How do I insert this jQuery plugin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
直接从 CDN 获取。将此代码粘贴到页面的 HEAD 上:
然后像使用常用的 javascript 代码一样使用该库,如下所示:
Get it straight from the CDN. Paste this code on your page's HEAD :
Then utilize the library just as you would with your usual javascript code just like this one:
我认为您应该将标签回显到索引页,如下所示:
或者您在 中包含一个包含 jQuery 脚本的 HTML/PHP 文件。或者
您编写一个与相呼应的函数上面的标签:
I think you should echo the tag to your index page like this:
Or you include an HTML/PHP file that contains jQuery script in the <head></head> tag
Or you write a function that echo the <script></script> tag above:
是的,只需像对待 HTML 一样对待 JavaScript 和 jQuery 代码即可。服务器读取 PHP 代码,PHP 代码告诉服务器将什么发送到浏览器,然后浏览器读取 jQuery 和 HTML。
Yes, just treat the JavaScript and jQuery code as you would HTML. The server reads the PHP code and the PHP code tells the server what to send to the browser, and the browser is what reads the jQuery and HTML.