我想知道究竟location.search.substring(1)做了什么.我在某个网站上看到了这段代码.我尝试使用打印alert,但这没有给出任何结果.它应该提醒位置href吗?
alert(location.search.substring(1))
Run Code Online (Sandbox Code Playgroud) 我想在变量中存储"+"运算符.
<head>
<script type="text/javascript">
var m= function(a,b){
return a-b
}
var jj= 10 m 10;
alert(jj)
</script>
</head>
Run Code Online (Sandbox Code Playgroud) 我的函数运行完美,没有使用附加的类,div但当我尝试class在元素上添加一个它不起作用.
<head>
<script type="text/javascript">
function showt(id){
$('body').append(id)
}
</script>
</head>
<body>
<a href="#" id="hidemain" onmouseover='showt("<div class='sdf'>appended</div>")'>show detail</a>
</body>
Run Code Online (Sandbox Code Playgroud) 即使一个跨度可见,我也要提醒"可见".但是,当我运行我的功能时,它不会发出警报.示例代码链接
//脚本
if($('.none').find('span').css('display')!='none'){
alert('visible')
}
Run Code Online (Sandbox Code Playgroud)
// HTML
<div class="none">
<span style="display:none">first</span>
<span style="display:block">second</span>
</div>
Run Code Online (Sandbox Code Playgroud)
// CSS
.none{display:none}
Run Code Online (Sandbox Code Playgroud) 我在函数中有一个变量,我想从其他函数访问它.我无法定义这个变量的功能.我设置了示例代码以供审核.http://jsfiddle.net/VC6Wq/1/
function one(){
var zero= 500;
}
function two(){
alert(zero)
}
Run Code Online (Sandbox Code Playgroud) 我阅读了有关计时事件的信息。我很困惑setTimeout:我有一个关于 W3Schools 的例子,它每 500 毫秒运行一次。我读到setTimeout它只工作一次。关联
<head>
<script>
function startTime() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
setTimeout(function(){startTime()},500);
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
Run Code Online (Sandbox Code Playgroud)