如何显示来自服务器的 html 下拉框中的数据?
how to display as it is data on html dropdown box coming from server?
如下从服务器获取数据
Test Your Code
New Testing Code
Opel Audi
Above data have sapace between the words. i want to show text as it
is.
我有 html select 下拉菜单,我在其中呈现服务器数据。
but i am not able to diplay data as it is coming form server, it is
showing one space in between the word. can anyone tell me how to fix
this?
<html>
<body>
<select>
<option value="volvo">Test Your Code</option>
<option value="saab">New Testing Code </option>
<option value="opel">Opel Audi</option>
</select>
</body>
</html>
检查plunkr
HTML 将删除 1 space 之后的所有 space。只需将 space 替换为
(不间断 space 点)
str = str.replace(/\s/gmi, ' ');
编辑:忘了分号
您可以使用字符串替换方法
str = str.replace("", ' ');
尝试使用空白字符
而不是空格。在您的情况下,您需要相应地修改来自服务器的文本。
如下从服务器获取数据
Test Your Code
New Testing Code
Opel Audi
Above data have sapace between the words. i want to show text as it is.
我有 html select 下拉菜单,我在其中呈现服务器数据。
but i am not able to diplay data as it is coming form server, it is showing one space in between the word. can anyone tell me how to fix this?
<html>
<body>
<select>
<option value="volvo">Test Your Code</option>
<option value="saab">New Testing Code </option>
<option value="opel">Opel Audi</option>
</select>
</body>
</html>
检查plunkr
HTML 将删除 1 space 之后的所有 space。只需将 space 替换为
(不间断 space 点)
str = str.replace(/\s/gmi, ' ');
编辑:忘了分号
您可以使用字符串替换方法
str = str.replace("", ' ');
尝试使用空白字符
而不是空格。在您的情况下,您需要相应地修改来自服务器的文本。