Question: I have 10 `divs`

```
<div id="div_1" class="myDivs"></div>
<div id="div_2" class="myDivs"></div>
<div id="div_3" class="myDivs"></div>
...

```

O want to select 5 of them with a click handler using jQuery.

```
$(".myDivs").on("click", function() {
    console.log('all clicked DIVs IDs...');
}

```

Is there a functionality to do this with jQuery? I would like to click them and get all IDs of the clicked `divs`. Thanks for your help!

Answer: 
This does the trick:

```
$(".markDIV").on("click", function (evt) {
    if (evt.ctrlKey)
        $(this).toggleClass("marked");
});

```
Toggle a class on each clicked div, then get an array of the ids of the divs with the class. The clicking of CTRL is a little redundant when using `div` elements. Try this:

```
$(".myDivs").on("click", function() {
    $(this).toggleClass('selected');
    var selectedIds = $('.selected').map(function() {
        return this.id;
    }).get();
    console.log(selectedIds);
});

```

[**Example fiddle**](https://jsfiddle.net/0ez6oppn/)