简体   繁体   English

在jquery中更改click事件

[英]Change the click event in jquery

I think this seems to be a quite common question, but since I am new to J Query, I couldn't understand other solutions, so thought to put my problem and be specific. 我认为这似乎是一个相当普遍的问题,但由于我是J Query的新手,我无法理解其他解决方案,所以想到解决我的问题并具体说明。

I have an anchor tag: 我有一个锚标记:

<a href="#" id="isActive" onclick="javascript: toggleThisDiv(this.id);" style="float: left;" title="Expand/Collapse">
<img src="arrow_down.gif" border="0">
</a>

When I click on it, it calls the javascript function which hides the existing div. 当我点击它时,它会调用隐藏现有div的javascript函数。 Now after this, I want to change the anchor tag's click event, so that when I click on the same anchor again, it refreshes the page. 在此之后,我想更改锚标记的click事件,这样当我再次单击同一个锚时,它会刷新页面。

Thanks a lot in advance for any solution. 非常感谢您提供任何解决方案。

function toggleThisDiv(id) {
    // do your other stuff in this function

    document.getElementById(id).onclick=function() {
        location.reload(true);
    };
}
document.getElementById("isActive").onclick = function();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM