:root Selector - Javascript jQuery Selector

Javascript examples for jQuery Selector:root

Description

The :root selector selects the document's root element, which is always the <html> element.

The following code shows how to Set the background color for the HTML document to yellow:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(":root").css("background-color", "yellow");
});//from  w  w  w.  ja v a2s  .c  o m
</script>
</head>
<body>

<h1>This is a heading</h1>

</body>
</html>

Related Tutorials