Each jQuery selector starts with this $() , this sign is called a factory function, this factory function is written before working on jQuery. Like selecting tag name, class, id and more.
Syntax:
$().function-name ()
Example :
<!DOCTYPE html> <html lang='en' xmlns='http://www.w3.org/1999/xhtml'> <head> <meta charset='utf-8' /> <title></title> <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script> <script type='text/javascript'> $(document).ready(function () { $('div').click(function () { $(this).css({'background-color':'red'}); }); }); </script> <style> body { margin: 10px; padding: 10px; } div { background-color: cyan; color: white; text-align: center; font-size:20px; height:100px; line-height:80px; } </style> </head> <body> <div id='div1'>Click me for changing the background-color </div> </body> </html>
Output: