werty1001,
а так?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo by werty1001</title>
<script type='text/javascript'>
window.onload=function(){
(function() {
var show = document.querySelectorAll('[data-show]');
var div = document.querySelectorAll('[data-div]');
for (var i=show.length; i--;) {
if (!show[i].addEventListener) {
show[i].attachEvent("onclick",(function(el) { return function() {document.querySelector("[data-div="+ el.getAttribute('data-show') +"]").style.display = 'none';}})(show[i]));
} else {
show[i].addEventListener("click", function() { document.querySelector("[data-div="+ this.getAttribute('data-show') +"]").style.display = 'none';});
}
}
})();
}
</script>
</head>
<body>
<span data-show="val">раз</span> <br /><br />
<span data-show="valval">два</span> <br /><br />
<div data-div="val">блок val</div> <br /><br />
<div data-div="valval">блок valval</div>
</body>
</html>