各位大神好,如何根据页面元素的ID点击按钮跳转到指定的页面,拿html和JavaScript语言来实现

在html页面中有商品的图片和商品的ID,商品下边有一个按钮,如何实现根据商品的ID点击按钮跳转到指定的页面,用html语言和javascript语言来实现,希望高手能提供html和javascript的代码,非常感谢!

不清楚你在问什么
<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

}
}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答