Test, check if jquery works?

Test, check if jquery works?

Important

You need to place the script src (cdn) before the jquery script.

For example:

5
6
7
8
9
10
11
12
13
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<pre lang="LANGUAGE" line="2">
<script>
$(document).ready(function(){
    var color = "red";
    $("body").css("background-color", color);
});
</script>

If you place the jquery cdn after the js code, it will not work.

Sometimes jquery doesn’t work. The cdn is not compatible. These cdn from google actually work.

1
2
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

And also a simple jquery function that will make the background red for all the page. If you don’t see the red background, it means that jquery doesn’t work.

2
3
4
5
6
7
<script>
$(document).ready(function(){
    var color = "red";
    $("body").css("background-color", color);
});
</script>

Another simple script. That will put “test” inside every paragraph html tag.

3
4
5
<script>
$( "p" ).append( "<p>test</p>" );
</script>

If you have questions, leave in the comments.

Add a comment: