嘿那里,我有以下代码:
sVal = analogRead(potPin); // read the value from the sensor
valMin = min(sVal, 1);
valMax = max(sVal, 128);
constrain(sVal,valMin,valMax);
itoa(sVal, res, 10);
println(res);
println(" ");
delay(150);
clearScreen();
Run Code Online (Sandbox Code Playgroud)
现在由于某种原因,gLCD屏幕上的输出几乎总是1023.我希望电位器的最小值为1,最大值为128.
As my last question was closed for being "too vague" - here it is again, with better wording.
I have a "grid" of li's that are loaded dynamically (through JavaScript/jQuery), the Array isn't huge but seems to take forever loading.
So, SO people - my question is:
Am I being stupid or is this code taking longer than it should to execute?
现场演示: http ://jsfiddle.net/PrPvM/ (非常慢,可能会挂起您的浏览器)
完整代码(下载): http ://www.mediafire.com/?xvd9tz07h2u644t
片段(来自实际的数组循环):
var gridContainer = $('#container');
var gridArray = …Run Code Online (Sandbox Code Playgroud) 我有一个<li>嵌套在一个包含内<ul>,我想要的是计算偏移量.而拥有的左上角<ul>是0, 0.
所以我的HTML是:
<div style="margin: 0 auto; width: 760px; height: 760px; overflow: hidden;">
<ul style="width: 2000px; height: 2000px; min-height: 2000px; position: relative;">
<li style="position: relative; width: 40px; height: 40px;"></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
我目前的jQuery是:
thePos = $('ul li').offset();
alert('X = '+thePos.left+', Y = 'thePos.top);
Run Code Online (Sandbox Code Playgroud)
但是,这是返回的偏移量0, 0.我猜它是计算相对于文档边缘而不是父容器的偏移量.
我怎么能绕过这个?
感谢您.
注意:position()也没有检索到正确的数字:(
基本上,我正在尝试UIViewAnimationTransitionCurlUp一个UIButton.动画效果很好,但按钮停留在那里.
即按钮向上卷曲,但按钮的另一个实例仍然在下面.
我的代码如下:
[UIButton beginAnimations:nil context:nil];
[UIButton setAnimationDuration:0.5];
[UIButton setAnimationBeginsFromCurrentState:YES];
[UIButton setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIButton commitAnimations];
Run Code Online (Sandbox Code Playgroud) 我想让jQuery附加一个style ="text-align:left;" 到我页面上的所有元素.
我知道我可能要做的事情如下:
$('everything-in-the-page').each( ...
Run Code Online (Sandbox Code Playgroud)
但是我对如何选择每个HTML标签感到有点困惑.
只需要停止BACKLASH: 这是一个可访问的站点(仅限打印).所以,是我知道这是不好的做法.
有没有办法在Javascript/jQuery中对背景图像应用"模糊"效果?
[编辑]通过"模糊"我的意思是高斯/运动模糊而不是投影:)
谢谢.
$(document).keydown(function(e) {
嗯,这是我的代码 - 我想知道是否有可能有这样的东西:
$(document).not('#pinkElephant').keydown(function(e) {
(除了,这不起作用......)
有任何想法吗?
非常感谢!
ps所有函数都在其中,是一个switch声明.
[编辑]嘿家伙n gals - 我不能,return false;因为我需要输入的元素是<input>文本,所以键盘仍然需要返回这里.
这让我很困惑:(
mysql_query("INSERT INTO dictionary ('word', 'definition') VALUES ('".$word."','".$definition."');")
Run Code Online (Sandbox Code Playgroud)
那只是不会执行,当我echo- 它得到这个:
INSERT INTO dictionary ('word', 'definition') VALUES ('monkey','monkey');
Run Code Online (Sandbox Code Playgroud)
因此值得正确地被带入其中,如果我出去,mysql_error()我得到:
您的SQL语法有错误; 查看与您的MySQL服务器版本对应的手册,以便在第1行''word','definition'VALUES('monkey','monkey')附近使用正确的语法
有任何想法吗?我很难过.
我正在做codeacademy.com jQuery课程,以便在我阅读jQuery In Action书籍之前获得jQuery的好品味,而且我已经完成了一部分而且代码不起作用,我不明白为什么.
我在这里创建了一个jsFiddle http://jsfiddle.net/weacY/
以下是codeacademy.com的说明:
大!接下来,让我们一起包含我们的function关键字和两个新动作:mouseenter()和fadeTo().
mouseenter()执行您可能期望的操作:当鼠标进入给定的HTML元素时,它会产生更改.例如,
$(document).ready(function(){$('div').mouseenter(function(){$('div').hide();});}); 一旦鼠标悬停在页面上,它就会隐藏在页面上的每一个.(我们将在下一课中找到如何影响其中一个.)现在,我们只有一个,所以这个设置没问题.
但是,我们将fadeTo()放在mouseenter()中,而不是hide().fadeTo()在其括号之间采用两个参数或输入,用逗号分隔:淡入淡出的速度和淡入淡出的不透明度(或透明度).例如,
fadeTo('fast',0.25); 会迅速将目标元素淡化到其原始不透明度的25%,使其非常浅色.
使用上面的例子,当你的鼠标进入'div'时,使你的'div'淡化为1(100%)不透明度.使动画速度"快".(确保以顺序速度为fadeTo()提供输入,然后是不透明度.)
将鼠标悬停在"div"上即可看到效果!
这是HTML:
<html>
<head>
<title>Button Magic</title>
<link rel='stylesheet' type='text/css' href='stylesheet.css'/>
</head>
<body>
<div><br/><strong>Click Me!</strong></div>
<script>type="text/javascript" src="script.js"</script>
</body>
</html>?
Run Code Online (Sandbox Code Playgroud)
这是CSS:
div {
height: 60px;
width: 100px;
border-radius: 5px;
background-color: #69D2E7;
text-align: center;
color: #FFFFFF;
font-family: Verdana, Arial, Sans-Serif;
opacity: 0.5;
}?
Run Code Online (Sandbox Code Playgroud)
最后是jQuery:
$(document).ready(function() {
$("div").mouseenter(function() {
$("div").fadeTo("fast", 1);
});
});?
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助.
我有一个这样的事件:
var CountDemKeys;
document.body.addEventListener('keypress', function() {
CountDemKeys++;
if (CountDemKeys % 10 === 0) {
alert("WOO HOO!");
}
});
Run Code Online (Sandbox Code Playgroud)
并在一个单独的功能:
RemoveShizzle = function() {
document.body.removeEventListener('keypress');
};
Run Code Online (Sandbox Code Playgroud)
但事件仍在发生:(
注意:我也尝试将事件设置为null:document.body.addEventListener('keypress', null);
document.body.addEventListener('keypress', null);
Run Code Online (Sandbox Code Playgroud)
没有快乐......
jquery ×6
javascript ×5
html ×2
arduino ×1
c ×1
c++ ×1
css ×1
iphone ×1
mysql ×1
objective-c ×1
optimization ×1
php ×1