出于某种原因,我不能使用jQuery.
这是我的代码:
document.addEventListener("touchstart", function(e) {
e.preventDefault();
var orig = e.originalEvent;
var x = orig.changedTouches[0].pageX;
var y = orig.changedTouches[0].pageY;
//id("#draggable").css({top: y, left: x});
id("draggable").style.left = x;
id("draggable").style.top = y;
Run Code Online (Sandbox Code Playgroud)
});
使用jQuery,你可以获得originalEvent,但如果你不使用它,如何获得它?
谢谢
这是我的代码:
a = [(1,2),(5,6)]
b = [(3,4),(7,8)]
print zip(a,b)
Run Code Online (Sandbox Code Playgroud)
它显示:
[((1, 2), (3, 4)), ((5, 6), (7, 8))]
Run Code Online (Sandbox Code Playgroud)
但我想得到:
[(1, 2, 3, 4), (5, 6, 7, 8)]
Run Code Online (Sandbox Code Playgroud)
那我该怎么办
谢谢
这是我的代码:
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
alert(minutes+"/"+hours+"/"+month + "/" + day + "/" + year)
Run Code Online (Sandbox Code Playgroud)
但是,我觉得很难比较两次,
我能做什么 ?
谢谢
这是我的代码:
var b;
while(!b){
setTimeout(function(){
alert('sss')
b=1;
}, 500);
}
Run Code Online (Sandbox Code Playgroud)
它不会提醒'sss'
我能做什么?
更新:
我想在谷歌地图v3上受到限制:
function get_bounds(){
var bounds_;
while(!bounds_){
setTimeout(function(){
bounds_=map.getBounds();
if(bounds_){
var leftBottom=[bounds_.getSouthWest().lat(),bounds_.getSouthWest().lng()]
var rightTop=[bounds_.getNorthEast().lat(),bounds_.getNorthEast().lng()]
return [leftBottom,rightTop];
}
}, 500);
}
}
Run Code Online (Sandbox Code Playgroud)
updated2:
嗨patrick dw,我不知道为什么,但你的代码不起作用:
var b;
function waitForB() {
setTimeout(function(){
if(!b)
waitForB();
else
alert('sss');
}, 500);
}
waitForB()
Run Code Online (Sandbox Code Playgroud)
updated3:
现在好了:
var b;
function waitForB() {
setTimeout(function(){
if(!b){
waitForB();
b='ss';
}
else{
alert('sss')
}
}, 500);
}
waitForB()
Run Code Online (Sandbox Code Playgroud) 这是我的代码:
function getRandom_marker(bounds) {
var leftBottom=[bounds.getSouthWest().lat(),bounds.getSouthWest().lng()]
var rightTop=[bounds.getNorthEast().lat(),bounds.getNorthEast().lng()]
var latlng=[leftBottom[0]+Math.floor(Math.random() * (rightTop[0]-leftBottom[0])),
leftBottom[1]+Math.floor(Math.random() * (rightTop[1]-leftBottom[1]))]
return latlng
}
Run Code Online (Sandbox Code Playgroud)
我使用此代码生成随机,但有时,标记不在地图范围内,
那么,我的代码有什么问题?
谢谢
更新:
这是代码有Math.abs:
而这不是:
这是我的代码:
<div id="box" style="border:1px solid red;height:100px;width:150px;position:relative;background:#eee">
<div id="head" style="background:black">drag me</div>
<div id="content" contenteditable=true style="border-bottom:1px solid red;height:70px;margin-bottom:5px;"> edit it </div>
<input id="ok" type="button" value="ok"/>
<input id="cancel" type="button" value="cancel"/>
</div>
Run Code Online (Sandbox Code Playgroud)
并且脚本是:
$('#box').draggable()
Run Code Online (Sandbox Code Playgroud)
演示在这里:http://jsfiddle.net/VRxZe/
谢谢
这是我的代码:
(r'^q/(?P<terminal_id>[^/]+)/(?P<cmd_type>[^/]+)/?$', 'send_query_cmd'),
Run Code Online (Sandbox Code Playgroud)
观点是:
def send_query_cmd(request, terminal_id, cmd_type):
Run Code Online (Sandbox Code Playgroud)
关于?p卑鄙的.
我不知道这个网址是什么意思,
谢谢
这是我的代码:
class fun:
def __getattr__(self,key):
return self[key]
def __setattr__(self,key,value):
self[key] = value+1
a = fun()
a['x']=1
print a['x']
Run Code Online (Sandbox Code Playgroud)
而错误是:
AttributeError: fun instance has no attribute '__getitem__'
Run Code Online (Sandbox Code Playgroud)
当我把它改为:
class fun:
def __getattr__(self,key):
return self.key
def __setattr__(self,key,value):
self.key = value+1
a = fun()
a.x=1
print a.x
Run Code Online (Sandbox Code Playgroud)
错误是:
RuntimeError: maximum recursion depth exceeded
Run Code Online (Sandbox Code Playgroud)
我能做什么,我想得到 2
我有一个这样的列表:
a=[1000,200,30]
Run Code Online (Sandbox Code Playgroud)
我想得到一个这样的列表:
['01000','00200','00030']
Run Code Online (Sandbox Code Playgroud)
那我该怎么办
谢谢
这是我的kvs.erl:
-module(kvs).
-export([start/0, store/2, lookup/1]).
start() -> register(kvs, spawn(fun() -> loop() end)).
store(Key, Value) -> rpc({store, Key, Value}).
lookup(Key) -> rpc({lookup, Key}).
rpc(Q) ->
kvs ! {self(), Q},
receive
{kvs, Reply} ->
Reply
end.
loop() ->
receive
{From, {store, Key, Value}} ->
put(Key, {ok, Value}),
From ! {kvs, true},
loop();
{From, {lookup, Key}} ->
From ! {kvs, get(Key)},
loop()
end.
Run Code Online (Sandbox Code Playgroud)
当我启动erlang时使用:erl -name zhao -setcookie abc
然后:rpc:call(fifar @ huihua.sohu-inc.com,kvs,store,[weather,cold]).
它显示错误:
(zhao@zjm1126.sohu-inc.com)1> rpc:call(fifar@huihua.sohu-inc.com,kvs,store,[weather,cold]).
** exception error: bad argument in an arithmetic expression …Run Code Online (Sandbox Code Playgroud)