开发者

click on div: do this, click on link inside div: do something else

开发者 https://www.devze.com 2023-02-20 19:09 出处:网络
i have some div element that scrolls to another position, when you click on it. but now i also want to include links into that div..

i have some div element that scrolls to another position, when you click on it. but now i also want to include links into that div.. now when i click, the link gets called plus the div scrolls. i want to prevent the div from scrolling, when hitting a href..

any idea?

jsfiddle (this example is n开发者_Python百科ot scrolling at all, but i want it to alert the href, when click on an href element, or stay undefinded, when no href element is around..)


It looks like you need two onclicks, one on the div, one on the a in the div. Something like this, perhaps? http://jsfiddle.net/HfYmv/8/

0

精彩评论

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