---
title: "What is the factory function in JQ?"  
description: "What is the factory function in JQ?"  
author: "Ethan Karla"  
published: 2021-07-28  
canonical: https://answers.mindstick.com/qa/93820/what-is-the-factory-function-in-jq  
category: "web application"  
tags: ["web development", "web application development"]  
reading_time: 2 minutes  

---

# What is the factory function in JQ?

What is the [factory](https://www.mindstick.com/forum/2362/what-is-dynamic-factory-in-mvc) [function](https://www.mindstick.com/articles/43970/purchase-suitable-wedding-dresses-for-your-wedding-function) in JQ?

## Answers

### Answer by Ravi Vishwakarma

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:

![What is the factory function in JQ?](https://answers.mindstick.com/questionanswer/f6f1c2fb-1adb-43d8-8994-f2ae93401e1b/images/58b3b086-da4e-45ad-9a0e-2b753f482f69.png)

\


---

Original Source: https://answers.mindstick.com/qa/93820/what-is-the-factory-function-in-jq

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
