Javascript 如何在javascript中给空间?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7400220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 02:08:49  来源:igfitidea点击:

How to give space in javascript?

javascript

提问by Vivek

I have a response where I have an Image in that response and after every response I need to give a space.How can I do that?

我有一个回复,在该回复中有一个图像,每次回复后我都需要留出一个空间。我该怎么做?

Any help will be appreciated!

任何帮助将不胜感激!

Here is my script:

这是我的脚本:

<script type="text/javascript>
    $("#thumbnail").append(response)
</script> 

回答by Vivek

<script type="text/javascript>
    $("#thumbnail").append(response +'&nbsp;')
</script>

回答by Null Pointer

try this

尝试这个

<script type="text/javascript>
$("#thumbnail").append(response)
$("#thumbnail").append("&nbsp;");
</script> 

回答by user278064

Using css:

使用css

#thumbnail img {
   margin-right: yourspace;
}

回答by ilivewithian

Are you looking for the &nbsp;html character? or are you looking to apply a padding or margin?

您在寻找&nbsp;html 字符吗?或者您是否希望应用填充或边距?

回答by Quentin

It depends on what sort of space you want.

这取决于你想要什么样的空间。

Determine what markup and styling you want. Maybe a literal " ", maybe a margin.

确定您想要的标记和样式。也许是字面的“”,也许是边距

Add the appropriate CSS to your stylesheet, then write JS that adds the appropriate markup.

将适当的 CSS 添加到您的样式表,然后编写添加适当标记的 JS。