I've assigned the same function to 2 different div elements. I'd like the function to determine which div element called the function by it's id. No jquery.
Am just not sure how to compare values with in the I assume would be sufficient if statement.
<head>
<script>
var x = document.getElementById('one')
var y = document.getElementById('two')
function foo(){
if(????){
x.style.color='red'
}
else if(????){
y.style.color='red'
}
}
</script>
<style>
#one, #two{width:50px; height:50px; border: solid black 5px;}
</style>
</head>
<div id='one' onclick='foo()'>hello</div>
<div id='two' onclick='foo()'>world</div>
Basically have div 'one' || 'two' call function foo() and have one of the responsible ID's properties changed.