I have a JavaScript code that toggles between DIV's on-click, but it doesn't work on IE (v.11.4) and I can't seem to understand what part is not suitable for IE..
Below is the simplified version of my code. For some reason it didn't work on jsfiddle but if you copy it in a plain html file it works fine on Chrome and Firefox, but not IE..
<!doctype html>
<html>
<head>
<title>Test</title>
<meta charset="UTF-8">
</head>
<body>
<style>
.holder>div {
display: none;
}
[dir=second]>.txt2,
[dir=first]>.txt1 {
display: block;
}
.holder_2>div {
display: none;
}
[dir=second_2]>.txt2_2,
[dir=first_2]>.txt1_2 {
display: block;
}
</style>
<div class="container1">
<button onclick="toggle('first')" class="clickme">Some text</button>
<button onclick="toggle('second')" class="clickme">Some other text</button>
<div class="holder">
<div class="txt1">
<h1>Some content here</h1>
</div>
<div class="txt2">
<h1>Some different content here</h1>
</div>
</div>
</div>
<div class="container2">
<button onclick="toggle_2('first_2')" class="clickme">Some text</button>
<button onclick="toggle_2('second_2')" class="clickme">Some other text</button>
<div class="holder_2">
<div class="txt1_2">
<h1>Some content here</h1>
</div>
<div class="txt2_2">
<h1>Some different content here</h1>
</div>
</div>
</div>
<script>
var holder = document.querySelector(".holder");
function toggle(val) {
holder.setAttribute('dir', val);
}
var holder_2 = document.querySelector(".holder_2");
function toggle_2(val) {
holder_2.setAttribute('dir', val);
}
</script>
</body>
</html>
Is it possible that the problem could even be in the CSS? All works well with Chrome and Firefox.