这是一个相当容易的,但我似乎无法弄明白.
基本上我有一个jquery悬停,在div中消失并在悬停时淡出另一个.
当我快速上下几次时,它会来回脉冲约3-4秒,以完成所有淡入/淡出.
我通常使用.stop()停止这些事情,但它似乎没有在这里做的伎俩.如果我在an` $(".txtWrap")之前将鼠标悬停在按钮上,我怎么能杀死淡入淡出.停止().悬停(
$(".txtWrap").stop().hover(
function () {
$(this).find('.txtBock').fadeOut();
$(this).find('.txtDesc').fadeIn();
},
function () {
$(this).find('.txtBock').fadeIn();
$(this).find('.txtDesc').fadeOut();
}
)
Run Code Online (Sandbox Code Playgroud) 试着用Javascript而不是jQuery思考,所以我想知道我是否正确行事.
我想在循环结束时进行回调.这是正确的方法吗?
for(var i = 0; i < divs.length; i++) {
/* do some stuff */
if ( i === (divs.length - 1)) { /* call back */ }
}
Run Code Online (Sandbox Code Playgroud)
我应该补充一点,我并不是说JSON请求回调就像循环结束时那样.
我有一个非常简单的Angular应用程序,我已经提炼到以下内容:
var napp = angular.module('Napp',['ngResource']);
var CompanyCtrl = function($scope, $routeParams, $location, $resource) {
console.log($routeParams);
};
napp.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/company/edit/:id',
{templateUrl: '/partials/edit', controller: 'CompanyCtrl'}
);
}]);
Run Code Online (Sandbox Code Playgroud)
和HTML:
<div ng-controller="CompanyCtrl"></div>
Run Code Online (Sandbox Code Playgroud)
当我记录$ routeParams时,它出现空白.当我使用.otherwise()时,它将加载我在那里指定的任何内容.知道我错过了什么吗?
我经常想要嵌套元素,例如以下导航:
ul
li
a(href="#") link Name
li
a(href="#") link Name
li
a(href="#") link Name
Run Code Online (Sandbox Code Playgroud)
有可能把李和一个放在同一条线上吗?一些语法li > a会很好.
使用护照JS成功登录时出现此错误.登录后尝试重定向到主页.
执行它的代码:
app.post('/login',
passport.authenticate('local', {failureRedirect: '/login' }),
function(req, res) {
res.redirect('/');
});
Run Code Online (Sandbox Code Playgroud)
完全错误:
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (http.js:644:11)
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?不确定为什么会发生这种错误.我仍然可以使用该应用程序,我只是不想要错误.
使用MongoDB 2dsphere存储GEOJSON并在lat/lng的某些商店中我不断收到以下错误:
{
"code": 16755,
"index": 0,
"errmsg": "Can't extract geo keys: { _id: ObjectId('586ff135b79aa00b84181bfb'), name: \"Austin\", slug: \"Austin\", description: \"\", twitter: \"\", facebook: \"\", instagram: \"\", author: ObjectId('57b60fed8620b56af460d5c5'), tags: [], created: new Date(1483731253640), location: { address: \"Austin, TX, United States\", coordinates: [ 30.267153, -97.74306079999997 ], type: \"Point\" }, __v: 0 } longitude/latitude is out of bounds, lng: 30.2672 lat: -97.7431",
"op": {
"name": "Austin",
"slug": "Austin",
"description": "",
"twitter": "",
"facebook": "",
"instagram": "",
"author": "57b60fed8620b56af460d5c5",
"_id": "586ff135b79aa00b84181bfb",
"tags": …Run Code Online (Sandbox Code Playgroud) 看起来很简单,但我无法让它工作.
我有两个div'类'用户'.我想输出"你有2个div".
<script type="text/javascript">
$(document).ready(function() {
function divcount() {
var mycount = $('.user').length();
document.write(mycount)
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
我确定我错过了一些简单的东西..
我有一个文件夹/文件的对象,如下所示:
{
about.html : {
path : './about.html'
},
about2.html : {
path : './about2.html'
},
about3.html : {
path : './about3.html'
},
folderName : {
path : './folderName',
children : {
sub-child.html : {
path : 'folderName/sub-child.html'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
并且它可以在有孩子的文件夹的6-7级深度.
我想找到路径等于我提供的字符串的对象.无论它有多深.
我使用只有顶级的下划线:
_.findWhere(files,{path:'./about2.html'}
Run Code Online (Sandbox Code Playgroud)
如何进行深度嵌套搜索.下划线是否具有此功能,或者我是否需要使用递归构建mixin?
我有一张我清楚关注的表格.我已经选择了整个表单,除了单击它时提交按钮变为空白外,它的效果很好.
如何从以下代码中排除我对输入#input的输入?
$(".wpcf7-form input, .wpcf7-form textarea").focus(function() {
if( this.value == this.defaultValue ) {
this.value = "";
$(this).addClass('filled');
}
}).blur(function() {
if( !this.value.length ) {
this.value = this.defaultValue;
$(this).removeClass('filled');
}
});
Run Code Online (Sandbox Code Playgroud) 我很难让减压器变热.
我正在使用Webpack和react-transform-hmr.有了这个,当我保存时,所有的CSS和组件都是热加载的,但是当我尝试使用其他类型的类型时 - 最明显的是减速器 - 它会告诉我进行全面刷新.
我发现这是因为我需要明确地重新加载reducers并接受事件.我在我的代码中使用的是store.js:
if(module.hot) {
module.hot.accept('./reducers/', () => {
const nextRootReducer = require('./reducers/index');
store.replaceReducer(nextRootReducer);
});
}
Run Code Online (Sandbox Code Playgroud)
reducers/index 导出根减速器.
但是现在当我运行它时它仍然告诉我[HMR] Cannot check for update (Full reload needed并且还有错误说[HMR] TypeError: currentReducer is not a function
所以 - 我需要一些帮助才能让它发挥作用.代码可以在https://github.com/wesbos/Simple-Redux上找到,你可以通过这样做来重现它:
npm installnpm startposts.js并将第6行的数字更改为其他任何内容javascript ×6
jquery ×3
angularjs ×1
count ×1
express ×1
flux ×1
google-maps ×1
hover ×1
lodash ×1
mongodb ×1
mongoose ×1
node.js ×1
passport.js ×1
reactjs ×1
redux ×1
ruby ×1
slim-lang ×1
templating ×1
webpack ×1