当isset我编码时遇到致命错误。我已经搜索了stackoverflow,但结果并不令人满意。
我正进入(状态
致命错误:不能在表达式的结果上使用isset()(可以使用“ null!== expression”代替)
我的密码是
if (!isset( $size || $color )) {
$style = '';
}else{
$style = 'font-size : ' . $size . ';color:' . $color;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用导航下拉列表,它有几个下拉选项.所以我想添加一个类,move-left如果它离开视口边缘.
我试过,getBoundingClientRect();但它给了我以下错误:
未捕获的TypeError:el.getBoundingClientRect不是函数
我的浏览器是chrome最新版本.
我的代码是:
var isElemInViewport = function(el){
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}
var el = $('ul.nav-menu li ul li ul');
$('ul.nav-menu li ul li').hover(function(){
if(!isElemInViewport(el)){
alert('o ya')
}
}, function(){
if(!isElemInViewport(el)){
alert('no more')
}
})
Run Code Online (Sandbox Code Playgroud) 我有一个返回变量的函数为true.第一个变量是false,如果发生的事件变为true.通过这个真实状态,我想执行另一个函数.
var showContents = false,
if(showContents = true){
$('.element').click(function(){
close();
})
}
var show = function(){
return showContents = true
}
Run Code Online (Sandbox Code Playgroud)