-4

Simple jquery will not load

    <script src="jquery-3.1.1.min.js" type="text/javascript">
    $(document).ready(function(){
        $("#p1").on("click", function(){
            $("#p1").slideUp(300);
        });
    });
</script>

If you could please help, because I cannot work with jQuery!

j08691
  • 204,283
  • 31
  • 260
  • 272

1 Answers1

1

You should make sure you give separate <script> tags. You cannot have src as well as content with the same tag. Have two tags for each src and the content like below:

<script src="jquery-3.1.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("#p1").on("click", function(){
            $("#p1").slideUp(300);
        });
    });
</script>

Also, another best practise is, if both the target and source are same, you can make use of this:

$("#p1").on("click", function(){
    $(this).slideUp(300);
});
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252