小编gkm*_*hit的帖子

动态创建<p>标签

当我点击"添加P2"按钮时,我想在id = p1和id = p3之间添加ap标签.

谢谢

这是我到目前为止的代码.

function addParagraphs()
{ 
    var p2 = "<p>paragraph 2</p>";
    document.getElementsById("p1").appendChild(p2);
}
Run Code Online (Sandbox Code Playgroud)
<p id ="p1" > paragraph 1</p>
<p id ="p3" > paragraph 3</p>
<p id ="p4" > paragraph 4</p>
<input id="b2" type='button' onclick='addParagraphs()' value='Add P2'/>
Run Code Online (Sandbox Code Playgroud)

html javascript dom

8
推荐指数
2
解决办法
2万
查看次数

检查一行是否以grep的特定字符串开头

我有一个文件app.log

Oct 06 03:51:43 test test
Nov 06 15:04:53 text text text 
more text more text
Nov 06 15:06:43 text text text
Nov 06 15:07:33
more text more text
Nov 06 15:14:23  test test
more text more text
some more text 
Nothing but text
some extra text
Nov 06 15:34:31 test test test
Run Code Online (Sandbox Code Playgroud)

我如何使用11月06日开始的所有线路?

我试过了

grep -En "^[^Nov 06]" app.log
Run Code Online (Sandbox Code Playgroud)

我无法获得其中有06的线条.

shell grep

6
推荐指数
1
解决办法
3万
查看次数

ssh eval“ $(ssh-agent -s)返回非法的变量名

为什么eval语句返回

Illegal variable name

$ eval "$(ssh-agent -s)"
Illegal variable name.
Run Code Online (Sandbox Code Playgroud)

ssh eval ssh-keygen

4
推荐指数
1
解决办法
2484
查看次数

当按下enter时运行javascript函数 - JavaScript只有Jquery

你好我在按Enter键时试图运行一个javascript函数.到目前为止,这是我的代码

我的HTML

<!DOCTYPE html>
<html>

<head>
    <title>JS Bin</title>
</head>

<body>
    <div>
        <form id="inputForm">
            <label for="userInput">Input : </label>
            <span id="userInputSpan">
                <input type="text" id="userInput" onkeydown="readInput(this)" />
            </span>
        </form>
    </div>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

我的JAVASCRIPT

function readInput(e) {
    if (e.keyCode == 13) { // 13 is enter key
        // Execute code here.
        // var temp = e.value;
        // console.log(temp);
        alert(e.value);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的JSBin

html javascript

3
推荐指数
1
解决办法
2154
查看次数

标签 统计

html ×2

javascript ×2

dom ×1

eval ×1

grep ×1

shell ×1

ssh ×1

ssh-keygen ×1