我刚刚开始使用JavaScript,我遇到了一些问题.
如何使用innerHTML适当性来更改此元素中的文本:
(function showArray(){
var names = new Array("Bob ","Alice ","Ceaser ","David");
names.sort();
for (var i = 0; i < names.length; i++) {
document.getElementById("loop").innerHTML = names[i];
// I'm only getting "David" as output!!
}
})();Run Code Online (Sandbox Code Playgroud)
<p id="loop">David Alice Bob Ceaser</p>Run Code Online (Sandbox Code Playgroud)
对不起,标题不好,我不确定如何更好地解释我的问题。请随时将其更改为更好的内容。
此外,我对flexboxes还是陌生的,这使得查找问题变得更加困难。因此,我设置了一个JSFiddle来展示我的问题。
/* Layout */
#pagecontentwrapper {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
min-height: 100%;
padding: 25px;
}
/* Inhalte */
#flexcontainer {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
}
/* Flex */
.rowParent,
.columnParent {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-direction: normal;
-webkit-box-orient: horizontal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-pack: start; …Run Code Online (Sandbox Code Playgroud)我在这里创建了一个JSFiddle问题
这适用于Firefox v33和v33.1,但是在34-35中失败了.这适用于Chrome和IE11.它可能是Firefox中的一个错误,但我不确定.基本上我有HTML看起来像这样:
.container {
position: absolute;
width: 150px;
}
.innercontainer {
position: relative;
padding-right: 25px;
margin-bottom: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.outerwrapper {
display: block;
height: 24px;
text-align: center;
font-size: 10px;
line-height: 24px;
margin-bottom: 5px;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
box-orient: horizontal;
-webkit-box-orient: horizontal;
flex-direction: normal;
-ms-flex-direction: normal;
-moz-flex-direction: normal;
-webkit-flex-direction: normal;
}
.wrapper {
flex: 1;
-ms-flex: 1 0 auto;
-moz-flex: 1;
-webkit-flex: 1;
-webkit-box-flex: 1;
display: -webkit-box; …Run Code Online (Sandbox Code Playgroud)我目前正在为我的网站处理一些警报消息,我想在左侧图标中放置一个将放在我的警报消息中:
.alert {
padding: 20px;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
}
.alert p::before {
content: "";
background: red; /* Some icon */
width: 20px;
height: 20px;
float: left;
margin-right: 5px;
}
.alert.success {
background-color: rgb(221, 255, 181);
color: rgb(139, 195, 74);
}Run Code Online (Sandbox Code Playgroud)
<div class="alert success">
<p>Hae duae provinciae bello quondam piratico catervis mixtae praedonum a Servilio pro consule missae sub iugum factae sunt vectigales. et hae quidem regiones velut in prominenti terrarum lingua positae ob orbe eoo monte Amano …Run Code Online (Sandbox Code Playgroud)我想为数组赋予一些属性,但前提是它们是数组索引.否则一些实现可能会将底层结构切换到哈希表,我不希望这样.
例如,这些是数组索引:"0","1","2","3","4","4294967294"
但这些都不是:"abcd","0.1","-0","-1"," 2","1e3","4294967295"
有没有一种简单的方法来测试字符串是否是数组索引?
我有一个由嵌套 UL 和 LI 组成的菜单,例如:
.wrapper > ul:first-child > li:last-child {
color: red;
}Run Code Online (Sandbox Code Playgroud)
<div class="wrapper">
<ul>
<li>Lorem</li>
<li>Ipsum</li>
<li>Dolar</li>
<li>Style me!
<ul>
<li>Lorem</li>
<li>Don't style me!</li>
</ul>
</li>
</ul>
</div>Run Code Online (Sandbox Code Playgroud)
我想向<li>第一个的最后一个添加样式<ul>,但不让它的子级(嵌套的<ul>)继承它。
我努力了:
.wrapper > ul:first-child > li:last-child {/*styles*/}
Run Code Online (Sandbox Code Playgroud)
但这仍然对最后一个元素进行样式设置。
有人知道我如何才能只定位那 1 个元素(仅使用 CSS)吗?
这令人非常沮丧,特别是考虑到它的简单性.简单的javascript:
<script type="text/javascript">
var name = new Array("cat","dog");
document.write(name[1]);
</script>
Run Code Online (Sandbox Code Playgroud)
这个脚本打印:"a"(如"cat"中的"a"...又名[0] [1] ......).
然而,当我将其更改为document.write(name)时,它会打印整个数组(即"cat,dog").为什么对于上帝的爱是这个简单的数组无法打印整个字符串(应该是"狗")?!
我有两张桌子
CREATE TABLE Categories (
Category INTEGER,
Id INTEGER,
FOREIGN KEY (Category) REFERENCES CategoriesInfo(Category)
)
CREATE TABLE 'CategoriesInfo' (
'Category' INTEGER PRIMARY KEY NOT NULL,
'Name' TEXT
)
Run Code Online (Sandbox Code Playgroud)
有索引
CREATE UNIQUE INDEX idxCategory ON Categories (Category, Id)
Run Code Online (Sandbox Code Playgroud)
如果我跑
EXPLAIN QUERY PLAN
SELECT CategoriesInfo.Category, Name
FROM Categories, CategoriesInfo
Where Categories.Category=CategoriesInfo.Category AND Id=:id
ORDER BY Name
Run Code Online (Sandbox Code Playgroud)
它说
Array
(
[0] => Array
(
[selectid] => 0
[order] => 0
[from] => 1
[detail] => SCAN TABLE CategoriesInfo (~1475 rows)
)
[1] => …Run Code Online (Sandbox Code Playgroud) 嗨,我需要一个正则表达式的帮助..如果有可能我不确定..
输入字符串: Will you [B] meet me [A] in the [E] end
我希望所有不在[]括号内的字符被其他字符替换; 让我们说一段时间.并且[]括号也被相同的字符替换.
如此理想的输出: ..........B...........A..........E.....
另一个例子:[A]red[B]elephant[C]hello[D]
输出:.A.....B..........C.......D.
如果有人可以提供帮助,那我试着解释得最好.
谢谢.
我用CSS做了一个心.我只是想找到一种方法让它击败/搏动.
这是代码(小提琴):
#heart {
position: relative;
width: 100px;
height: 90px;
}
#heart:before,
#heart:after {
position: absolute;
-webkit-animation: heart 1s linear infinite;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: red;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}Run Code Online (Sandbox Code Playgroud)
<div id="heart"></div>Run Code Online (Sandbox Code Playgroud)