我正在尝试创建一些按钮,根据单击的按钮显示一个框.我这样做是通过给每个盒子自己的类并将一个参数传递给一个函数来识别哪个盒子是目标.然后我将此函数分配给页面上的每个按钮的onclick属性(我知道我应该将事件处理程序附加到单独的文件中).这是功能:
var show = function(boxNumber){
if($(this).hasClass('shown')){
$(this).removeClass('shown');
$(this).html('Show');
$('.box'+boxNumber).fadeOut(1000);
}
else{
$(this).html('Hide');
$(this).addClass('shown');
$('.box'+boxNumber).fadeIn(1000);
}
};
Run Code Online (Sandbox Code Playgroud)
html:
<span onclick="show(1)">Box 1</span>
<div class="box1"></div>
etc. for more boxes
Run Code Online (Sandbox Code Playgroud)
但是,此功能不起作用.首先,this关键字似乎不是以按钮为目标,因为按钮的html在点击时不会改变.但是,当我用按钮的类替换this关键字时,它工作正常.
其次,该功能可以精确地淡化框,但如果再次单击该按钮则不会隐藏它们.
我被卡住了所以任何帮助将不胜感激!谢谢.
XAMPP 3.1.0无法正常工作,因为端口80正在使用中.我环顾四周,这似乎是一个常见的问题.我已经停止了IIS,Skype没有运行,Web部署代理服务正在运行,我已经根据这个问题的第二个答案更改了Apache的httpd.conf的配置来监听端口80:XAMPP PORT 80很忙/ Apache配置文件中的EasyPHP错误:但仍然没有运气.以下是XAMPP控制面板中的错误消息:
2:03:49 PM [Apache] Problem detected!
2:03:49 PM [Apache] Port 80 in use by "system"!
2:03:49 PM [Apache] Apache WILL NOT start without the configured ports free!
2:03:49 PM [Apache] You need to uninstall/disable/reconfigure the blocking application
2:03:49 PM [Apache] or reconfigure Apache to listen on a different port
2:03:49 PM [Apache] XAMPP Apache is already running on port 443
2:03:49 PM [mysql] MySQL Service detected with wrong path
2:03:49 PM [mysql] Change XAMPP …
Run Code Online (Sandbox Code Playgroud) 我正在使用if语句和PHP的$ _SERVER ['HTTP_REFERER']来检查用户是否来自主页并执行某些功能,如果他们这样做:
if($_SERVER['HTTP_REFERER'] == htttp://www.example.com {
//some code
}
Run Code Online (Sandbox Code Playgroud)
问题是主页有时会在URL中传递GET变量,PHP的$ _SERVER ['HTTP_REFERER']方法会将带有GET变量的URL视为不同的URL,因此除非用户来自,否则不会触发if函数主页没有传递GET变量.
我想在有人来自主页时触发if语句,无论是否传递了GET变量,任何帮助都将不胜感激!
fadeout ×1
get ×1
http-referer ×1
javascript ×1
jquery ×1
onclick ×1
php ×1
port80 ×1
xampp ×1