我的HTML:
<input type="button" id="toggleButton" value="toggle" />
<h3 id="disclaimer"> We do not guarentee the validity of the data </h3>
Run Code Online (Sandbox Code Playgroud)
的JavaScript/jQuery的:
$("#toggleButton").click( function() {
if($("#toggleButton").is(":visible")){
$("#disclaimer").hide();
}else {
$("#disclaimer").show();
}
});
Run Code Online (Sandbox Code Playgroud)
免责声明应该在隐藏和可见之间切换,每当按下按钮时,隐藏免责声明就好了,但一旦隐藏它就不会再次变得可见.
在这方面需要帮助.
我有一个函数,按下时获取密钥代码.
这是我的代码:
function Getkeycode(e){
var keycode = null;
if (window.event)
keycode = window.event.keyCode;
else
keycode = e.which;
return keycode;
}
window.onkeydown = function(){
alert(Getkeycode()); // I'm tried to using Getkeycode() or Getkeycode(e) but still error
}
Run Code Online (Sandbox Code Playgroud)
以前的代码在Internet Explorer中运行良好,但在Firefox中始终会出现错误消息>> e is undefined或e is not defined
这是一些示例代码的链接。
在开始测试之前,我假设a的返回值setTimeout()将是某种浏览器对象。
实际上,这似乎是一个简单的整数。我还相信,将的返回值分配给setTimeout全局变量将意味着只能有一个这样的对象。但是,如您所见,如果您多次单击“启动计时器”按钮,则可以同时运行多个计时器。
例如
timeout 1,由于五秒钟内起火timeout 2timeout 1要在四秒钟和timeout 2五秒钟之内开火timeout 2清除可以通过始终在设置之前清除当前超时变量来解决用户单击创建多个计时器的问题。但是我真的很想了解Javascript在这里实际上在做什么。
我想使用'鼠标拖动'在框内拖动背景的位置.
css:
.filmmakers #map {
width : 920px;
height : 500px;
margin-top : 50px;
margin-left : 38px;
border : 1px solid rgb(0, 0, 0);
cursor : move;
overflow : hidden;
background-image : url('WorldMap.png');
background-repeat : no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
html:
<div id = "map" src = "WorldMap.png" onmousedown = "MouseMove(this)"> </div>
Run Code Online (Sandbox Code Playgroud)
javascript:
function MouseMove (e) {
var x = e.clientX;
var y = e.clientY;
e.style.backgroundPositionX = x + 'px';
e.style.backgroundPositionY = y + 'px';
e.style.cursor = "move";
}
Run Code Online (Sandbox Code Playgroud)
什么都没有发生,没有错误,没有警告,什么都没有......我尝试了很多东西:div内部的绝对定位图像(你可以猜到为什么不起作用),一个带有背景图像的div内的可拖动div,一个拖放的表,最后我尝试了这个:
function MouseMove () …Run Code Online (Sandbox Code Playgroud) 我正在尝试动态添加元素,并在JQuery中为它们单击侦听器.无论出于何种原因,当我单击元素的"删除"按钮时,removeGroup事件不会被设置.任何帮助都会很棒,谢谢.
$('.removeGroup').click(function(event){
alert();
});
cartPopper.click(function(event){
$('#selectedGroupList').find('.selected').remove();
for(group in selectedGroups)
{
var group_id = selectedGroups[group];
var name = $('.' + group_id).text();
$('#selectedGroupList')
.append
(
'<li style="font-size:20px" class="selected ' + group_id + '">'
+ '<a href="javascript: void(0);" class="">'
+ '<button class="btn btn-danger removeGroup" type="button">'
+ 'Remove'
+ '<text class="groupValue" style="display: none;">'
+ group_id + '</text></button></a>'
+ name
+ '</li>'
);
}
cartPop.show();
});
Run Code Online (Sandbox Code Playgroud) 如何禁用右键单击?或者,禁用上下文菜单。
并在此说明如何检测上/下鼠标右键?
这不是为了防止人们获取内容或其他内容。我正在开发游戏,我也希望能够使用右键单击功能。
我想更改默认打印机名称,使用JavaScript代码,下面的代码成功打开打印对话框,但我想设置我们自己的打印机名称.客户端所有打印机名称都已将其保存在数据库中.可以静态或动态更改.
<!DOCTYPE html>
<html>
<head>
<script>
function printpage()
{
window.print();
}
</script>
</head>
<body>
<input type="button" value="Print this page" onclick="printpage()" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
提前致谢
<div id="block_msg" style="width:250px;border: solid 1px red;margin: 15px">
<div id="text_msg1">111?????111</div>
<input type="submit" onclick="clickon(**<<<HERE I WANT SEE DIV ID TEXT_MSG1>>>**)" value="????????">
</div>
Run Code Online (Sandbox Code Playgroud)
我如何获得id ="text_msg1"并将其放入onclick.怎么样?谢谢!
我有一个名称空间对象,我在其上定义了一些函数.其中一个函数用于创建到远程服务器的websocket会话.
ns.Session = function(url, config, callback){
var ws = new WebSocket(url);
ws.onmessage = function (e){
if(login(e.data)){
// This is the point at which I need to pass back the session object to callback
callback(session):
}
}
....
}
Run Code Online (Sandbox Code Playgroud)
在JavaScript中,据我知道,如果有人调用使用此功能ns.Session(....),则this对象将是纳秒.那么,我如何获得要发送给回调的"会话" 实例.
arguments.callee据我所知,已被弃用.
我这样做的全部原因是,在服务器确认登录之前,会话不被视为"可用",因此我不希望在实际连接和登录之前过早地返回功能对象.因此使用一个回调.如果有更好的方法来实现这一点,我也对此持开放态度.
会议有一堆的其他内部功能,如addHandler,sendData我还没有在这里显示为简洁起见,等等.
var inputs = document.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++)
{
if (document.getElementById("value_[0-9]"))
{
alert('found: ' + inputs[i].value);
}
else
{
alert(inputs[i].value);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用条件来获取仅以value_开头的输入ID
if (document.getElementById("value_[0-9]"))
Run Code Online (Sandbox Code Playgroud)
但在我的表单中有5个或更多ID时,没有任何内容.即value_1,value_2,value_3等.
javascript ×10
html ×2
jquery ×2
callback ×1
css ×1
dom ×1
dynamic-data ×1
mouseevent ×1
settimeout ×1
websocket ×1