小编brg*_*brg的帖子

Ruby小数点后没有任何零点

我已经搜索了很多,以获得我float在十进制后获得没有不需要的零值的确切要求.

Eg:  14.0 should be 14
     14.1 should be 14.1
Run Code Online (Sandbox Code Playgroud)

到目前为止我找到的最近可能的解决方案是使用sprintf():

irb(main):050:0> num = 123.0
=> 123.0
irb(main):051:0> sprintf('%g', num)
=> "123"
Run Code Online (Sandbox Code Playgroud)

这里的问题是我的num类型更改为StringFloat.我可以在不更改类型的情况下获得浮点值更改吗?

ruby floating-point

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

在javaScript中获取Div的最外层父ID

嗨,在我的情况下,我使用以下结构中的div.

<div id="Parent1">
    <div>
        <div>
            <div id="mychildDiv"></div>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我的工作场景:

我知道子div的id,从那个如何得到父id.对于此示例,想要获取id Parent1.有可能获得最外层的父ID吗?

html javascript jquery

2
推荐指数
1
解决办法
3077
查看次数

单击按钮时重复 div

下面的代码用于重复一个 div。但它不起作用。请帮我。

<html>
  <head>
    <script>
      $(".repeat").live('click', function () {
        var $self = $(this);
        $self.after($self.parent().clone());
        $self.remove();
      });
  </script>
  </head>
  <body>
    <form>
      <div class="repeatable">
        <table border="1">
        <tr><td><input type="text" name="userInput[]"></td></tr></table>
        <button class="repeat">Add Another</button>
      </div>
    <input type="submit" value="Submit">
    </form>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

html javascript jquery repeat

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

如何用JavaScript创建一组单选按钮?

有谁知道为什么这个简单的程序不起作用?这是一个用Javascript创建一组单选按钮的程序.

<html>
  <head>
    <script>
      function onWriteRadio(Valuse,numButtons,RadioName){
        for(i=0;i<numButtons;i++){
          document.write("<input type='radio' name=" + RadioName + "value="       +Valuse[i]+"/>");
          document.write("<br/>");
        }
      }
    </script>
  </head>

  <body onload="onWriteRadio([red,green,blue],3,'color')>

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

javascript

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

openssh-server无法在Docker容器中启动

我有一个奇怪的问题.

我无法ssh到具有IP地址的docker容器172.17.0.61.

我收到以下错误:

$ ssh 172.17.0.61
ssh: connect to host 172.17.0.61 port 22: Connection refused
Run Code Online (Sandbox Code Playgroud)

Dockerfile确实包含openssh-server安装步骤:

RUN apt-get -y install curl runit openssh-server
Run Code Online (Sandbox Code Playgroud)

并且步骤开始ssh:

RUN service ssh start
Run Code Online (Sandbox Code Playgroud)

可能是什么问题?

当我进入容器使用nsenter并启动ssh服务然后我能够ssh.但是创建容器ssh-server似乎并没有开始.

我该怎么办?

openssh docker dockerfile

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

标签 统计

javascript ×3

html ×2

jquery ×2

docker ×1

dockerfile ×1

floating-point ×1

openssh ×1

repeat ×1

ruby ×1