javascript - jquery - 可以使文本消失但不能使隐藏文本可见

标签 javascript jquery dom hide show-hide

隐藏文本的链接有效,但 .show 隐藏文本的链接不显示它,而且我没有看到任何错误。请参阅 jsfiddle:http://jsfiddle.net/tv6WQ/

<head>
<style type="text/css">   
    #shortandlong {color:red}   
    #thestory {visibility:hidden} 
</style>
</head>
<body>
    <span id="shortandlong">This is the short version but click </span><a href="#" id="showme">here...</a><span id="thestory"> now this is the full version</span><br/>
<span id="hideit">This text can be hidden </span>by clicking here <a href="#" id="hideme">here</a><br/>

</body>

js:

  $(document).ready(function () 
    { $('#hideme').click(function() 
      { $('#hideit').hide('fast');     
        return false;     } );    
      $("#showme").click(function() 
      { $('#thestory').show;     
        alert('Hello World');     
        return false;     } );    
    } );

最佳答案

.1。

$('#thestory').show()

不是

$('#thestory').show

.2。将 visibility:hidden 替换为 display: none; 或通过 $('#thestory').css('visibility', 'visible'); 更改可见性

http://jsfiddle.net/pxStN/

关于javascript - jquery - 可以使文本消失但不能使隐藏文本可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9678021/

相关文章:

javascript - 可以使用 DOM 的 setAttribute 函数设置多个属性吗?

javascript - JS 创建的 html 链接不会在 chrome 中打开?

jquery - 透明覆盖 div 允许在 IE 7,8 中点击

javascript - 在 HTML select 元素中搜索和选择选项值

javascript - 如何将参数传递给 attachEvent Javascript 函数

javascript - 当不显示 div 时,忘记这个 css 规则

javascript - 在 iOS Safari 中禁用选择上下文菜单

javascript - 字符串到对象的转换?

Javascript变量似乎没有进入DOM

javascript - 使用带有 JavaScript 的离散标记检查元素是否关闭