-3

I am just a beginner so be easy on me

while (true){
//hide the paragraph
   $("para").hide()
//show the paragraph slowly
   $("para").show("slow")
}
p{
 font-size:1500%;
 text-align: center;
 margin:0;
}

body{
 background:yellow;
}
<!doctype html>
<html>
<head>
 <meta charset="UTF-8">
 <title>Document</title>
 <link rel="stylesheet" href="main.css">
</head>
<body>
 <p id="para">this is disco</p>
</body>
 <script src = "jquery.js"></script>
 <script src = "main.js"></script>
</html>

The jquery.js is the file name of the compressed jquery in my computer when i run it the page doesnt show up

3 Answers3

1
 while (true) { … }

will keep running forever (infinite loop) and block the UI, since JS is single threaded. It will also hide the paragraph over and over again. If you want to hide a paragraph you should use:

$(document).ready(function(){ 
    //hide the paragraph
    $("p#para").hide()
    //show the paragraph slowly
    $("p#para").show("slow");
})

to do all that stuff after the page has loaded.

If you would like to make the paragraph blink, so that it gets hidden after it showed up »slow«, you can do that using a timer, after the page has loaded:

(function blink () {
    $("p#para").hide()
    //show the paragraph slowly
    $("p#para").show("slow");

    setTimeout(blink, 1000);
})();

or a CSS animation.

If you want to make the text blink, you don't need to use JS at all. Have a look here: Imitating a blink tag with CSS3 animations

The »sliding« effect is caused by jQuery's show() method, documented here.

Community
  • 1
  • 1
philipp
  • 15,947
  • 15
  • 61
  • 106
-1

It must be $("#para"). $("para") searches for an element <para> which does not exist.

mm759
  • 1,404
  • 1
  • 9
  • 7
-1

The element id is "para",so for you to manipulate it the selector should be preceeded by "#" i.e "#para"

$(document).ready(function(){ 
//hide the paragraph
$("#para").hide()
//show the paragraph slowly
$("#para").show("slow")

})