If #marker is a child of #map-container, you dont need jquery - just use css and target the div accordingly. First set the base size and then set the size according to the parents classes.
#marker {
width: 25px;
}
#map-container.zoom-70 #marker,
#map-container.zoom-80 #marker {
width: 40px;
}
#map-container.zoom-100 #marker,
#map-container.zoom-130 #marker,
#map-container.zoom-150 #marker {
width: 70px;
}
If #marker is a sibling of #map-container, you still dont need jquery - just use css and target the div via the general sibling combinator "~". First set the base size and then set the size according to the siblings classes.
#marker {
width: 25px;
}
#map-container.zoom-70 ~ #marker,
#map-container.zoom-80 ~ #marker {
width: 40px;
}
#map-container.zoom-100 ~ #marker,
#map-container.zoom-130 ~ #marker,
#map-container.zoom-150 ~ #marker {
width: 70px;
}
If you absolutely, positivly have to use jquery - then you can use a switch statement which is always better than multiple if statements.
Note that multiple statements can be blocked together and then the default statement occurs if none of the preceding statements evaluate to true.
The following snippet demonstrates the different switch statements;
updateDiv();
$('#class-selector').change(function(){
document.querySelector('#map-container').className = 'zoom-' + $(this).val();
updateDiv();
})
function updateDiv() {
switch(true) {
case $('#map-container').hasClass('zoom-150'):
case $('#map-container').hasClass('zoom-130'):
case $('#map-container').hasClass('zoom-100'):
$('#marker').css("width", 70).text('70px');
break;
case $('#map-container').hasClass('zoom-80'):
case $('#map-container').hasClass('zoom-70'):
$('#marker').css("width", 40).text('40px');
break;
default:
$('#marker').css("width", 25).text('25');
}
}
#map-container {
border: solid 1px red;
padding: 15px;
}
#marker {
background: blue;
color: white;
text-align: center
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="map-container" class="zoom-100">
<p>This div with the red border is #map-container and the the following blue div is #marker. Changing the select list below will apply the different class to #map-container and will change the blue div accordingly.</p>
<label>Select a different size to apply to the div</label>
<select id="class-selector">
<option value="">None</option>
<option value="70">zoom-70</option>
<option value="80">zoom-80</option>
<option value="100" selected>zoom-100</option>
<option value="130">zoom-130</option>
<option value="150">zoom-150</option>
</select>
<hr/>
<div id="marker"></div>
</div>
hasClassaccepts only one parameter..hasClassworks, it expects a single class name as parameter. If you want to test if the element has any of these classes, then you need to join multiple hasClass calls using||