<ul>
    <li>Üst Menü
        <ul>
	        <li class="urunler">
		        <a href='#' class='selected'>Ürün 1</a>
		      </li>
	        <li class="urunler">
		        <a href='#'>Ürün 2</a>
		      </li>
        </ul>
    </li>
</ul>
body {
  margin: 0;
}

.yakinim {
  border-left: 1px solid  red;
}
const seciliEleman = document.querySelector('.selected');
seciliEleman.closest('ul').classList.add('yakinim');
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.