开发者

stop one of the parent click events from firing

开发者 https://www.devze.com 2023-02-09 07:29 出处:网络
HI, I am using a greybox on the following element: <a href=\"<? echo $rctiGrayBox; ?>\" class=\"greybox\" widt=\"800\" heigh=\"800\" id=\"rctiGrayBox\" title=\"RCTI\">View RCTI</a>

HI,

I am using a greybox on the following element:

<a href="<? echo $rctiGrayBox; ?>" class="greybox" widt="800" heigh="800" id="rctiGrayBox" title="RCTI">View RCTI</a>

This 'a' element is contained in TR which fires an event when ever we click 'View RCTI'. I can stop that click event from firing by using stop开发者_JAVA百科Propagation() but using this function also stops the greybox to work and instead of showing the data in greybox it shows the data on a new page.

Theoretically when i use stopPropagation() on my 'a' tag it stops the all the events from firing. I need a way with which i can only stop the click event on but should not stop any event related to Greybox.

Please help!!


You are looking for event.preventDefault().

That will prevent the default behavior (guess what..), in this case will stop the anchor from linking.

Demo: http://www.jsfiddle.net/KDU48/


<a href="" onclick="return false;"></a>

this will stop the bubble up event in the browser. But bound eventhandlers will still work

0

精彩评论

暂无评论...
验证码 换一张
取 消