Could someone explain why my logic is not working? ?
Clicking the PLUS symbol works as expected.
Clicking the MINUS symbol does NOT change with initial click
but works correctly everytime thereafter.
Am I not understanding the ‘ternary’ statement correctly?
Here’s the code
[code]
<html>
<head>
<title>Character Toggle</title>
<style type=”text/css”>
.charReplace { font-size:3em; cursor:pointer;
background-color:lime; width:1em;
text-align:center; font-weight:bold; }
</style>
</head>
<body>
Image showed should toggle plus or minus after INITIAL click<p />
<div class=”charReplace” value=’+’ onclick=”swapChar(this)”>+</div><br>
<div class=”charReplace” value=’-‘ onclick=”swapChar(this)”>-</div><br>
<div class=”charReplace” value=’+’ onclick=”swapChar(this)”>+</div><br>
<div class=”charReplace” value=’-‘ onclick=”swapChar(this)”>-</div><br>
<div class=”charReplace” value=’+’ onclick=”swapChar(this)”>+</div><br>
<script type=”text/javascript”>
function swapChar(info) {
info.value = (info.value == ‘-‘) ? ‘+’ : ‘-‘;
info.innerHTML = info.value;
}
</script>
</body>
</html>