For clarity, here is another example demonstrating erilem's answer with a map var and map div that are not named 'map'.
mapElement = '#mapDiv'
mymap = new ol.Map({
target: mapDiv,
view: new ol.View({
...
})
});
$(mapElement).data('map', mymap);
Then you can reference that map with jquery using data with the data method. In my case I then wanted to use the ol updateSize() to update mymap.
thisMap = $(mapElement).data('map')
thisMap.updateSize();
This is useful when I have more than one map on a page. Where I use:
mapDiv = id +'-map'
mapElement = '#' + mapDiv
maps[i] = new ol.Map({
target: mapDiv,
view: new ol.View({
...
})
});
$(mapElement).data('map', maps[i])
And then:
thisMapId = activeDataset + '-map'
thisMapElement = '#' + thisMapId
thisMap = $(thisMapElement).data('map')
thisMap.updateSize()
Where id = activeDataset