:target
selectorThe jQuery :root
selector is used to select the target element indicated by the fragment identifier of the document's URI.
:target
selector Syntax$(':target')
:target
selector ExamplesFollowing is a simple example which makes use of :target Selector.
Note:
intro
http://127.0.0.1:5500/test.html#intro
:target
selector<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>jQuery root selector example - Lautturi</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> </head> <body> <style>*:target { color : red }</style> <p id="intro">Introduce</p> <script> $(function(){ console.log($( ":target" )); //[<p id="intro">Introduce</p>] console.log($( ":target" ).length); // 1 }); </script> </body> </html>