开发者

make span selection go to parent div

开发者 https://www.devze.com 2023-03-04 08:47 出处:网络
I have a span inside a div. .myspan { float:right; } <div>john, doe<span class=\"myspan\">(male)</span></div>

I have a span inside a div.

.myspan {
    float:right;
}
<div>john, doe                    <span class="myspan">(male)</span></div>

Is th开发者_如何学编程ere a way if the user clicks or hovers over the span I can make those events go to the parent div?


The events bubble up to the parent element by default. You don't have to do anything.


If you want to access the parent, you can always say

(this).parent();

but i am not clear what is your requirement

as Matti said , by default events propogates to parent...

read this

http://api.jquery.com/event.stopPropagation/

0

精彩评论

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