Question: I have been working with Git (Bitbucket), and I know how to link multiple remote repositories to one local repository, as I have seen in many tutorials available online, like this <https://jigarius.com/blog/multiple-git-remote-repositories> and this <https://www.cloudsavvyit.com/2464/how-to-use-git-with-multiple-remote-repositories/>

What I am trying to achieve is little different. I have two remote repositories, say `repo1` and `repo2`. Both repositories contain 3 branches - `master` branch, `release/1.0` branch, and `release/2.0` branch. My project is a generic Java application. `repo1` contains only java files, while `repo2` contains only JAR files, which are binary files.

I don't have any dependency management system like maven. I am trying to achieve this - When I switch to `release/1.0` branch, my java files will change according to `repo1` and the JAR files should also change according to `repo2`. Similarly, when I switch to `release/2.0` branch, my java files should change according to `repo1` and the JAR files should also change according to `repo2`. JAR files are different in release branches.

I will not be pushing JAR files to `repo2`, I don't have such a use case. I will be pushing only Java files, that too, to `repo1`.

Is this possible? or is there any workaround to achieve this?

Thanks.

Answer: 
Whenever a button is triggered a click `event` is fired. To handle that event there are **3** ways in vanilla javascript:

### 1. Specifying the function to be called in an HTML tag.

```html
<button class="button2" onclick="addDie()">Add die</button>

```

### 2. Adding a handler in the button `onclick` property in JS.

```js
const button = document.getElementById("your_button_id");
button.onclick = function(event) {
// do something
}
// or in your case
button.onclick = addDie

```

### 3. Adding an event listener

With this approach, you can add any number of handler for your event in the button.

```js
button.addEventListener("click", addDie);
button.addEventListener("click", dieRoll);

```

These three are the possible ways to handle the events using vanilla JS.

### Since you are using jquery you can simply do,

```js
$("#button2").click(addDie)

```

### To make sure the events are attached safely you would need to wait till the document is loaded.

### 1. In Jquery

```js
$( document ).ready(function() {
...
$("#button2").click(addDie)
...
}

```

### 2. In Vanilla JS

```js
document.addEventListener("DOMContentLoaded", function(){
...
 button.addEventListener("click", addDie);
 button.addEventListener("click", dieRoll);
...
});

```

Knowing the above three ways will help you understand the ways events can be handled with vanilla js.
Based on the code you showed, I think the issue is that your script is in the `head` part, before the body (including the buttons) is even loaded.

That means that when you do `$("#button0")`, you get a collection of *zero elements* (the buttons don't exist yet), and then you attach a `click` handler to zero elements, so you are doing nothing.

The solution is simple: jQuery allows you in a very simple way to defer the execution of some code until the DOM has finished loading. That is done by calling `$` as a function and passing a callback, i.e. `$(...)` (or, more verbosely, by writing `$(document).ready(...)`):

```js
  $(function () {
      $("#button0").click(function(){
        diceRoll = 0
        for (i=diceAmt;i>0;i--) {
          diceRoll += rand(1, diceSides)
        }
        document.getElementById("dieRoll").innerHTML = diceRoll;
      })
  })

```

That should fix the issue.