单击链接时避免插入换行符

时间:2014-02-05 07:28:11

标签: javascript html css

这就是我在UI中所拥有的 -

View by Team <dropdown list> (OR) Click on image to navigate

当从下拉列表中选择特定团队时,UI会显示如下 -

View by Team <dropdown list>
Home

当我点击Home时,我希望UI为 -

View by Team <dropdown list> (OR) Click on image to navigate

但我正在将UI设为 -

View by Team <dropdown list> 
(OR) Click on image to navigate

在源代码中,我有 -

<div id="teamList"><select><options></select>
    <span id="text">(OR) Click on image to navigate</span>
</div>

在从下拉列表中选择团队的javascript函数中,我指定了 -

document.getElementById('text').style.display='none';

如何防止出现额外的换行符?

2 个答案:

答案 0 :(得分:0)

尝试在另一个范围内回家

    <!DOCTYPE html>
    <html>
     <head>
      <script src="http://code.jquery.com/jquery-2.1.0.js"></script>
      <script type="text/javascript">
        $(function(){
          document.getElementById('text').style.display='none';
        });
      </script>
     </head>
    <body> 
      <div id="teamList"><select><options></select>
        <span id="text">(OR) Click on image to navigate</span>
        <span>Home</span>
      </div>
    </body>
    </html>

这里是小提琴http://jsfiddle.net/BnFpJ/

答案 1 :(得分:0)

尝试将这个简单的CSS添加到你的div

#teamList{
white-space: normal;
}