我正在尝试使用以下脚本在dynamic page中隐藏按钮
<a class="hideonClick" id="venueButton" type="button">Find venue providers</a>
<script>
document.getElementById("venueButton").onclick = function() {hideButton()};
function hideButton(){
//get the button
venueButton.href="http://evopia.net/?providers-category=venues&catid=123&pagenum=1&viewtype=grid-4&numberofpages=&setorderby=&setorder=";
venueButton.style.display="none";
}
window.onload = init;
</script>
</pre>
问题是,我正在使用“ href”重定向到给定的链接,我只想在使用的“ href”链接上隐藏此按钮。请帮助使用哪种方法。
答案 0 :(得分:0)
您的问题有点令人困惑:
我正在使用“ href”重定向到给定的链接,我只想在使用的“ href”链接上隐藏此按钮
在我看来,您只想单击时隐藏链接。这就是我要使用的方法:
document.getElementById("venueButton").addEventListener('click', hideButton);
function hideButton(e) {
//this.href = "put your url here";
console.log('commented out setting href for example');
this.style.display = "none";
}
<a class="hideonClick" id="venueButton" type="button">Find venue providers</a>
如果您只是试图将数据加载到视图中,则应使用AJAX request using XMLHttpRequest
来获取数据,而不要通过将href
指向其自身的url来静态地重新加载页面。
答案 1 :(得分:-1)
我个人会在点击时添加一个cookie,如果是cookie,则在hide
上添加一个button
。