English 中文(简体)
jquery: 如何隐藏和显示
原标题:jquery: how to hide and show
  • 时间:2012-05-25 09:26:55
  •  标签:
  • jquery

我想在鼠标上隐藏并显示 lt; p> 标签, 但是我的代码只能隐藏 p 标签, 不再显示, 为什么?

<html>
  <head>
<script type="text/javascript" src="jquery.js"></script>
<script>
  $(function(){
    $("#mouse").mouseover(function(){
      if($(this).is( :hidden )){
        $(this).show("normal");
      }
      else{
       $(this).hide("slow"); 
      }
    });
  });
</script>
  </head>
  <body bgcolor="white">
   <p id="mouse">
     test
   </p>
 </body>
</html>
最佳回答

因为隐藏 p 上将不会出现鼠标过错事件 。

问题回答

当元素被隐藏时, 您无法使用它的任何事件 。 如果您不隐藏“ p ”, 最好只隐藏“ p ” 中的元素 。

示例

<script>
$(document).ready(function() {
  $(".hidden").hover(function () {
     $(".hidden span").toggle();
  });
});
</script>

<p class= hidden >please hover<span> Hide this text </span></p>




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签