我最近开始听到很多关于Node.js. 虽然我理解了它可以做的一些事情,即创建一个Web服务器,但我想知道你是否可以在生产环境中为我提供一个坚实的推理.
本文为使用Node.js作为开发工具奠定了坚实的基础,实质上说明它可以提供后端环境的可用性而无需后端体验.我也听说过很多开发人员在生产项目中使用Node.js(例如Codepen),但是当我在那里建立了Web服务器(如LAMP堆栈)时,我根本不明白它是如何有用的.
我很想花时间学习Node.js,因为它越来越受欢迎,但因为我确实有一个相当坚实的后端基础,我很好奇是否有必要.
简而言之,Node.js的一些最有用的方面是什么以及为什么有人需要在生产环境中使用?
我创建了一个非常基本的样本:
HTML
<div id="bla"></div>
Run Code Online (Sandbox Code Playgroud)
CSS
#bla {
width:400px;
height:400px;
background-color:green;
display:none;
}
#bla:hover{
background-color:red;
}
Run Code Online (Sandbox Code Playgroud)
你可以看到它是一个最初隐藏的DIV,当鼠标悬停在它上面时会改变颜色.
此JavaScript在2秒后取消隐藏
setTimeout(function() {
document.getElementById('bla').style.display="block";
},2000)
Run Code Online (Sandbox Code Playgroud)
但是,如果将鼠标放在DIV即将出现的位置 - 当它出现时 - 它会显示在未被覆盖的状态.只有当您实际移动鼠标时 - 才会发生悬停效果.
这是一个演示.运行它并立即将鼠标放在结果窗格上.
这是设计的吗?有没有办法(没有JS更好)来检测DIV 是否悬停?
任何人都可以告诉我为什么
[System.ComponentModel.ToolboxItem(false)]
在Asp.net Web服务中使用?
好的,我再也看不到了.我正在使用scrollTo插件并在我的网站上有一个scrollTo函数.它工作,现在突然间它没有......
这是我的代码:
$(document).ready(function() {
$('header').delay(300).fadeIn(750);
$('#intro_text').delay(800).fadeIn(750);
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
m4v: "mi4.m4v",
ogv: "mi4.ogv",
webmv: "mi4.webm",
poster: "mi4.png"
});
},
swfPath: "js",
supplied: "webmv, ogv, m4v",
size: {
width: "570px",
height: "340px",
cssClass: "jp-video-360p"
}
});
});
$(function(toDemos) {
$('h1').click(function() {
$.scrollTo('#intro', 800);
});
});
$(function(toDemos) {
$('#contact').click(function() {
$.scrollTo('footer', 800);
});
});
$(function(toDemos) {
$('#demos').click(function() {
$.scrollTo('#content', 800);
});
});
$(function(toDemos) {
$('#toTop').click(function() {
$.scrollTo('#intro', 800);
});
});
$(function() {
$("#playlist li").on("click", function() { …Run Code Online (Sandbox Code Playgroud) 我正在尝试从BLE设备读取数据,但始终出现权限错误。演示项目可以在这里找到:https : //github.com/sergiomtzlosa/CoreBluetooth-Demo(请记住-我的代码与此代码有些不同)。
一般而言,连接和读取值没有问题,但是有一些特征(必不可少)会导致权限错误。
控制台日志:更新错误!!!特征:“未知(<fff4>)”,错误:“不允许读取”。
因此,当我从该特性订阅或读取数据时,它每次都会向我发送NULL(可能的原因:没有读取权限)。
控制台日志:特征:“未知(<fff4>)”->值:(null)
这是一个代码段:
//Action on discovering services
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error
{
if (error)
{
NSLog(@"Discovered services for %@ with error: %@", peripheral.name, [error localizedDescription]);
return;
}
for (CBService *service in peripheral.services) {
NSLog(@"Discovereddddddddddd service %@", service.UUID);
[testPeripheral discoverCharacteristics:nil forService:service];
}
NSLog(@"didDiscoverServicesEnd");
}
//Action on discovered characteristics
- (void)peripheral:(CBPeripheral *)peripheral
didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {
NSLog(@"didDiscoverCharacteristicsForService!");
for (CBCharacteristic *characteristic in service.characteristics) {
NSLog(@"Discovered characteristic %@", characteristic.UUID);
NSLog(@"---------------------------------------------------");
NSLog(@"Reading value …Run Code Online (Sandbox Code Playgroud) 我知道这个问题在stackoverflow中非常熟悉,但我仍然找不到我的解决方案.当我点击父div时,我想得到我的孩子div的值,但是我当前的代码给了我"undefined".我的html如下:
<div class="main">
<div class="testId">
1
</div>
<div class="testName">
test
</div>
<div class="testDob">
10/10/10
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我的脚本如下
var id = $(this).child(".testId").innerHTML;
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
我正在进行基础调查,其中一个问题是肯定/没有问题.如果用户选择"否",我想在问题下方显示一个文本区域,以便用户解释他/她无法回答的原因.如果他们单击是,则文本框保持隐藏(或隐藏,如果他们单击否并显示它).
这是我的HTML片段(是的,我正在使用表格进行格式化:-).在这种情况下,它节省了我的时间).有4个是/否问题.这只是其中之一.它们之间唯一的区别是ID名称(#explain1,#explain2,#explain3,#explain4)
<tr id="yesno1">
<!-- yes/no1 choices --> <!-- Yes(1) No(0) -->
<td class="center"><input name="yn1" value="1" id="yes1" type="radio"></td>
<td class="center"><input name="yn1" value="0" id="no1" type="radio"></td>
<!-- yes/no1 question -->
<td class="question">
Did you meet your goals during this program? (If no, explain.)
</td>
</tr>
<tr class="explain-box" id="explain1">
<td></td>
<td></td>
<td class="explain-text">
<textarea name="explain1" placeholder="Please explain..."></textarea>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
这是我的jQuery.这适用于问题一:
$(function() {
$('.explain-box').hide();
$('#no1').click(function() {
$('#explain1').show();
});
$('#yes1').click(function() {
$('#explain1').hide();
});
});
Run Code Online (Sandbox Code Playgroud)
我对javascript和jquery相当模糊,所以我的问题是如何在不输入每个是/否问题的每个ID的条件的情况下使jquery代码工作?我知道我可以用this某种方式,但我不知道如何去做.有人可以提供在这种情况下使用的功能的想法吗?我是否应该咬紧牙关并输入每个问题条件,因为它只有4个问题?
我有以下代码(从这个问题中提取)来设置textareas的字符限制.
function maxLength(el) {
if (!("maxLength" in el)) {
var max = el.attributes.maxLength.value;
el.onkeypress = function () {
if (this.value.length >= max) return false;
};
}
}
var maxtext = document.getElementsByClassName("maxtext");
for (var i = 0; i < maxtext.length; i++) {
maxLength(maxtext[i]);
}
Run Code Online (Sandbox Code Playgroud)
以及我的textareas html示例:
<textarea maxlength="150" class="maxtext"></textarea>
Run Code Online (Sandbox Code Playgroud)
这一切在Firefox和Chrome中都运行良好.在IE7 +中,如果我输入限制,它将阻止我,但我可以无限制地复制/粘贴文本.
有没有办法修改此脚本以防止复制/粘贴超出最大字符限制?
我试图将#commentslink的颜色改为白色.我所有的其他字体样式(字体系列,大小)都在工作,只是颜色不会改变
我的HTML是这样的;
<div id="commentslink">
<div class="circle">
<p><a href="">10</a></p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
而我的CSS就是这个
a:link, a:visited {
color: #0eb0d3;
text-decoration: none;
}
a:hover {
color: #0eb0d3;
opacity: 0.4;
text-decoration: none;
}
#commentslink {
float: right;
font-color: #ffffff;
font-size: 19px;
font-family: 'Montserrat', sans-serif;
}
.circle {
float: right;
background-color: #f89b2d;
width: 32px;
height: 32px;
border-radius: 16px;
position: relative;
margin-top: -10px;
margin-right: 20px;
}
Run Code Online (Sandbox Code Playgroud) 我希望块从一个点到另一个点.在小提琴中你可以看到在动画之后,该块会回到它的第一个位置.
我怎么能防止这种情况?
css
div
{
width:100px;
height:100px;
background:black;
position:relative;
animation:myfirst 2s;
-webkit-animation:myfirst 2s; /* Safari and Chrome */
}
@keyframes myfirst
{
from { left:0px; top:0px; }
to { left:0px; top:200px; }
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
from { left:0px; top:0px; }
to { left:0px; top:200px; }
}
</style>
Run Code Online (Sandbox Code Playgroud)