elin-r
10/4/2016 - 10:29 AM

The Gothenburg Crew - Display bank details like Simon wants

The Gothenburg Crew - Display bank details like Simon wants

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  
<div id="bank">
    <p>SW</p>
</div>
  
<button class="bank">Switch</button>
  
</body>
</html>

<script type="text/javascript">
function a(el){
var str = document.getElementById("bank").innerHTML;
var res = str.replace("SW", "Swedbank");
document.getElementById("bank").innerHTML = res;
}
function b(el){
    var str = document.getElementById("bank").innerHTML;
    var res = str.replace("Swedbank", "SW");
    document.getElementById("bank").innerHTML = res;
}

$(".bank").click(function() {
  var el = this;
  return (el.t = !el.t) ? a(el) : b(el);
});
</script>