Home » Jquery » javascript – jquery and css hint needed $("elemet").css();-Exceptionshub

javascript – jquery and css hint needed $("elemet").css();-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I am trying to move the shape 200px down using $("#shape").css("top","200px");
and it does not work, any advice?

> <style type="text/css">
>         #shape{
>             width: 200px;
>             height: 200px;
>             background-color: red;
>             display: none;
>             position: :relative;
>             
>         }
>     
>     </style>
<div id="shape"></div>
<script type="text/javascript">
    //var start=new Date().getTime();

    function appear(){
        $("#shape").css("top","200px");
        $("#shape").css("display","block");
        start=new Date().getTime();
    }

</script>
How to&Answer:

do like this

<!DOCTYPE html>
<html>
<head>
   <title>your title</title>
</head>
<script 
src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> 
</script>
<style type="text/css">
  #shape{ width: 200px; height: 200px; background-color: red; display: none; 
  position:relative;

 }

</style>
<body>
  <div id="shape"></div>
  <script type="text/javascript">
  function appear(){
    $("#shape").css("top","200px");
    $("#shape").css("display","block");
    start=new Date().getTime();
 }
appear()
</script>
</body>
</html>