根据jQuery api,接受索引并返回DOM节点的.get()的补充操作.index()
可以获取DOM节点并返回索引.假设我们在页面上有一个简单的无序列表:
<ul>
<li id="foo">foo</li>
<li id="bar">bar</li>
<li id="baz">baz</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
.index()
将返回与其兄弟姐妹相关的匹配元素集中第一个元素的位置:
alert('Index: ' + $('#bar').index();
Run Code Online (Sandbox Code Playgroud)
我们回到列表项的从零开始的位置:
Index: 1
Run Code Online (Sandbox Code Playgroud)
我只是想知道,我们怎么能用JavaScript做同样的事情?
我最近一直在玩React 16.6.0并且我喜欢React Memo的想法,但我一直无法找到任何关于最适合实现它的场景.React docs(https://reactjs.org/docs/react-api.html#reactmemo)似乎没有暗示将其抛在所有功能组件上的任何含义.因为它需要进行浅层比较以确定是否需要重新渲染,是否会出现对性能产生负面影响的情况?像这样的情况似乎是实施的明显选择:
// NameComponent.js
import React from "react";
const NameComponent = ({ name }) => <div>{name}</div>;
export default React.memo(NameComponent);
// CountComponent.js
import React from "react";
const CountComponent = ({ count }) => <div>{count}</div>;
export default CountComponent;
// App.js
import React from "react";
import NameComponent from "./NameComponent";
import CountComponent from "./CountComponent";
class App extends Component {
state = {
name: "Keith",
count: 0
};
handleClick = e => {
this.setState({ count: this.state.count + …
Run Code Online (Sandbox Code Playgroud) 我希望在容器div中水平排序我的div.
我在JQuery网站上找到了一个例子,但这是垂直排序.我希望它是水平的.
我想做它排序#sortable
<div>
.
请您指导我如何以水平方式转换此垂直排序.
<style type="text/css">
#draggable1 { width: 150px; height: 35px; padding: 0.5em; }
#draggable2 { width: 150px; height: 35px; padding: 0.5em; }
#draggable3 { width: 150px; height: 35px; padding: 0.5em; }
#sortable { width: 700px; height: 35px; padding: 0.5em; }
</style>
Run Code Online (Sandbox Code Playgroud)
<script type="text/javascript">
$(function() {
$("#sortable").sortable({
revert: true
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
<div class="demo">
<div id="sortable" class="ui-state-default">
<div id = "draggable1" class="ui-state-default">Home</div>
<div id = "draggable2" class="ui-state-default">Contact Us</div>
<div id = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 intellij 中编写一个 javascript 测试,我需要为其导入一些依赖项,并且我想使用 ES6 样式的导入语句,但出现错误
/usr/local/bin/node /workspace/rr-sample/node_modules/mocha/bin/_mocha
--ui bdd --reporter "/Users/me/Library/Application Support/IntelliJIdea2019.1/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js"
tests/*.test.js /workspace/rr-sample/tests/App.test.js:3
import chai from 'chai'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1043:16)
at Module._compile (internal/modules/cjs/loader.js:1091:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
at Module.load (internal/modules/cjs/loader.js:976:32)
at Function.Module._load (internal/modules/cjs/loader.js:884:14)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at /workspace/rr-sample/node_modules/mocha/lib/mocha.js:334:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/workspace/rr-sample/node_modules/mocha/lib/mocha.js:331:14)
at Mocha.run (/workspace/rr-sample/node_modules/mocha/lib/mocha.js:809:10)
at Object.exports.singleRun (/workspace/rr-sample/node_modules/mocha/lib/cli/run-helpers.js:108:16)
at exports.runMocha (/workspace/rr-sample/node_modules/mocha/lib/cli/run-helpers.js:142:13)
at Object.exports.handler (/workspace/rr-sample/node_modules/mocha/lib/cli/run.js:292:3)
at Object.runCommand (/workspace/rr-sample/node_modules/yargs/lib/command.js:242:26)
at Object.parseArgs [as _parseArgs] (/workspace/rr-sample/node_modules/yargs/yargs.js:1087:28)
at Object.parse …
Run Code Online (Sandbox Code Playgroud) 我需要在用户选择的文本旁边放置一个绝对定位按钮.就像IE8在内部做的那样.
我正在将一个jQuery mouseup事件绑定到Document,并获取所选文本,但我目前没有关于如何知道实际选择位置的想法,而没有将其包装在某个元素中,因为选择文本可以是跨越几个元素,如果我将其包裹起来会使结构混乱.
我想在选择更改时获得选项的值和键.
我知道我可以onChange
在event.target.value
函数中使用选项的简单值,但是如何获得键?
<select onChange={this.onChangeOption} value={country}>
{countryOptions.map((item, key) =>
<option key={key} value={item.value}>
{item.name}
</option>
)}
</select>
Run Code Online (Sandbox Code Playgroud) 任何人都可以请赐教我的新Flexbox的布局模式是如何比任何现有的表的方式更好?(显示:表格和所有这些都包含在我的情况下)?
在IE10下它根本不受支持,这在不久的将来不是很好,而且我看不到桌面布局的任何好处.但是,互联网开始充满了这种新的CSS布局方法的"崇拜者",我看到的所有例子都可以很容易地用普通的css完成而没有问题.
更新25.12.15:
我一直在使用flexboxes,因为它们被引入现代浏览器并停止使用display:table
等等,因为flexboxes更强大且易于使用.
我正在运行,certbot --apache
但我收到以下错误:
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Obtaining a new certificate
Performing the following challenges:
Client with the currently selected authenticator does not support any
combination of challenges that will satisfy the CA.
Run Code Online (Sandbox Code Playgroud)
安装的版本0.10.2
在Debian 8.10上
我想升级到0.21.0,这应该解决问题https://community.letsencrypt.org/t/certbot-0-21-0-release/50725
但我尝试了apt-get update/upgrade,我得到以下内容:
certbot is already the newest version.
certbot set to manually installed.
Run Code Online (Sandbox Code Playgroud)
有关如何更新的任何建议?