js点击一个id后自动跳转到一个网址

JavaScript011

js点击一个id后自动跳转到一个网址,第1张

<a href="http://zhidao.baidu.com/" id="add-cart" class="btn" style="padding:6px 20px"><i class="icon-cart ie6png"></i> 点击跳转</a>

不清楚你在问什么

<button id="ss">商品id</button>

<button onclick="xxx('')">跳转页面按钮</button>//xxx('')改成xxx('跳转到指定网址')则跳转到指定网址

<script>

function xxx(ww){var u=document.getElementById("ss").innerHTML

if(ww!=""){window.location.assign(ww)

}else{window.location.assign("index.html?"+u)获取按钮上的id跳转到页面,id=1跳转到index.html?1,id=2跳转到index.html?2

}

}