I can immediately see one apparent bug:
if (dif == 'lijn') { ... }
The object
dif
cannot be compared with any string; it is an object representing HTML document. You don't need to check up anything at all. You find the element by the attribute
id
, but this attribute value should always be unique on page. Therefore, you either correctly find it, or not — it cannot possibly be "wrong element"; the whole idea is wrong.
You also should know that not found element is returned as null, and that you cannot search for elements added dynamically to your HTML DOM:
document.getElementById() — Web APIs.
Your way of hiding and showing an element is not the only one. Different methods give you different effects, first of all, it the ways the hiding affects the layout. Please see my answer which describes different methods, hopefully, more or less comprehensively:
How to show and hide div.
—SA