我目前正在尝试创建一个导航菜单,其中活动类应用于具有与当前URL匹配的href的锚点,因此我可以使该锚点的样式使其从菜单的其余部分中脱颖而出.
这是我的加价:
<div id="sidebar">
<h2>Navigation menu</h2>
<h2 class="subnav"><a href="menu1/menu_item1">Menu item 1</a></h2>
<h2 class="subnav"><a href="menu1/menu_item2">Menu item 2</a></h2>
<h2 class="subnav"><a href="menu1/menu_item3">Menu item 3</a></h2>
<h2 class="subnav"><a href="menu1/menu_item4">Menu item 4</a></h2>
<h2 class="subnav"><a href="menu1/menu_item5">Menu item 5</a></h2>
</div>
Run Code Online (Sandbox Code Playgroud)
这是jQuery:
jQuery(function($) {
// get the current url
var path = location.pathname.substring(1);
// defining the top subnav anchor
var $top_item = $('#sidebar h2:nth-child(2) a');
// defining all subnav anchors
var $all_items = $('#sidebar h2.subnav a');
// defining the anchors with a href that matches the current url
var …Run Code Online (Sandbox Code Playgroud) 我目前正在阅读David Golding的"Beginning CakePHP:从新手到专业".有一次我必须使用CLI命令"蛋糕烘焙",我得到欢迎屏幕,但当我尝试烘烤例如控制器时,我收到以下错误消息:
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 117
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 122
Warning: mysql_get_server_info(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 130
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 154
Error: Your database does not have any tables.
Run Code Online (Sandbox Code Playgroud)
我怀疑错误消息与php试图访问错误的mysql-socket,即默认的osx mysql-socket - 而不是MAMP使用的错误消息有关.因此,我更改了我的数据库配置以连接到UNIX mysql-socket(:/Applications/MAMP/tmp/mysql/mysql.sock):
class DATABASE_CONFIG …Run Code Online (Sandbox Code Playgroud) 我知道如何显示和隐藏终端中的隐藏文件 - 但是有没有办法在显示隐藏文件时隐藏某些文件,如.DS_STORE?可以说某些文件是超级隐藏的吗?
当使用jQuery的validation-plugin时,有没有办法只显示抛出的最新错误消息?
我想编写一个选择器,它针对没有特定类的第一个元素.
<ul>
<li class="someClass">item 1</li>
<li>item 2</li> <-- I want to select this
<li class="someClass">item 3</li>
<li>item 4</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我知道如何选择没有"someClass"的所有元素:
$('li not:(.someClass)').dostuff();
Run Code Online (Sandbox Code Playgroud)
但我不知道如何只选择没有"someClass"的第一个元素.
谁知道怎么做?
我目前正在开发一个必须包含大量图片参考的Google电子表格.
我想要实现的是:当您将鼠标悬停在单元格上时,会出现一个图像(如工具提示).
我在Google Developers上找到了这个小部件,但是当我将代码添加到我的电子表格时没有任何反应.
你们有谁知道怎么做这样的事吗?关于如何解决这个问题的任何提示都非常感谢!
我目前正在通过IBM关于CakePHP的教程
有一次,我遇到了这段代码:
<?php
class Dealer extends AppModel {
var $name = 'Dealer';
var $hasMany = array (
'Product' => array(
'className' => 'Product',
'conditions'=>, // is this allowed?
'order'=>, // same thing here
'foreignKey'=>'dealer_id'
)
);
}
?>
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到以下错误消息:"解析错误:语法错误,意外','在第7行的/Applications/MAMP/htdocs/cakephp/app/models/product.php"
我是PHP的n00b所以我的问题是:是否允许使用没有指定值的键创建数组?有没有人玩这个啧啧,知道是什么?
我正在使用jQuery Tools(http://flowplayer.org/tools/index.html)来创建工具提示,我创建了一个包含以下行的js文件:
$("div#example-0").tooltip('#example-0-tooltip');
$("div#example-1").tooltip('#example-1-tooltip');
$("div#example-2").tooltip('#example-2-tooltip');
$("div#example-3").tooltip('#example-3-tooltip');
Run Code Online (Sandbox Code Playgroud)
等等
如果有已知数量的example-div,这可以正常工作,但我希望这可以使用未知数量的example-div.
基本上我希望我的jQuery能够读取DOM树并确定有多少example-div,并以某种方式遍历它们并添加工具提示.
有人知道怎么做吗?
我在这篇文章中读到你可以使用^ =来检查字符串是否以某些东西开头.
我摆弄了这个例子:
var foo = "something-something";
if(foo ^= "something") {
alert("works!");
}
else{
alert("doesn't work :(");
}
Run Code Online (Sandbox Code Playgroud)
它不起作用 - 有人怎么做?
jsfiddle示例:http://jsfiddle.net/timkl/M6dEM/
有没有办法使用jQuery关闭输入字段的自动完成?
像这样:
<input type="text" autocomplete="off" />
Run Code Online (Sandbox Code Playgroud) jquery ×5
javascript ×4
cakephp ×2
php ×2
arrays ×1
macos ×1
mysql ×1
navigation ×1
terminal ×1
validation ×1