Vartan Israelyan Vartan Israelyan - 5 months ago 25
Javascript Question

How convert php line into javascript?

How can i convert this php-part into javascript function.

<li><a href="<?php if($path) {echo '/index.php#products';}else{echo 'javascript:void';} ?>" onclick="smoothScroll('products');">PRODUCTS</a></li>

ixe ixe
Answer

You mean this?

(window.location.pathname + window.location.hash) == 'index.php#products' ? 'index.php#products' : 'javascript.void'

window.location / W3Schools