0

I feel so bad having to post this. But, I have been banging my head to understand why this simple code doesn't work on any of my browsers. IE or Chrome or FF.

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#click").click(function(){
    $("#para").hide();
  })
}
</script>
</head>

<body>
<p id="para">Hai Rama Raju</p>
<button id="click">Click to hide the text</button>
</body>
</html>

And it doesn't work at all !!! I checked the Javascript on browser, it's enabled. I tried downloading the jquery file and still the issue persists. No clue !!!

4

2 回答 2

5

您没有准备好关闭文档)

$(document).ready(function(){
  $("#click").click(function(){
    $("#para").hide();
  })
}) // this line
于 2013-04-28T04:14:25.897 回答
0
$(document).ready(function () {
    $("#click").click(function () {
        $("#para").hide();
    });  // <-- Missing semicolon here...
});      // <-- Missing ) and semicolon here...

你可能也想试试这个:

$(document).ready(function () {
    $("#click").click(function () {
        $("#para").toggle();
    });
});

在没有参数的情况下,该.toggle()方法只是简单地切换元素的可见性。

于 2013-04-28T07:36:43.087 回答