如何将php行转换为javascript?

时间:2016-06-22 09:07:52

标签: javascript php

如何将这个php-part转换为javascript函数。

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

1 个答案:

答案 0 :(得分:0)

你是说这个意思吗?

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

window.location / W3Schools