javascript - Floating icon over a link does not receive mouse click event -


i want display icon floating on right side of link when mouse on link. idea able click on icon display dialog. works long no link text under icon. if text long icon on text link executed. icon click handler never called.

what can give icon priority on link? problem because icon floating?

+------------------------------------------------------+ | link                                |icon| +------------------------------------------------------+ 

the html looks this:

<div class="group-content ui-sortable">     <a title="gmail|http://mail.google.com/mail" class="link show-option "              href="http://mail.google.com/mail" target="google">         <span title="link.opensettings" class="ui-icon ui-icon-gear link-settings"              style="display: none; z-index: 9999;"></span>         <span class="ui-icon link-icon ui-icon-link ui-sortable-handle"></span>         gmail     </a>     ... more links ... </div> 

css:

.link-settings {     padding: 2px;     background-color:rgba(255, 255, 255, 0.2);     float: right;     z-index: 9999;   /** bring top ... */ } 

javascript: (called when page initialised. adds popup icon on links)

$('.link')     .prepend("<span class='ui-icon ui-icon-gear link-settings'></span>")     .hover(         function () {             $(this).find(".link-settings")                 .show()                 .css('z-index', '9999');         },         function () { $(this).find(".link-settings").hide(); }     )     .click(function () {         console.log("link clicked");     }) ; 

the span inside link..so of course link works..you're still clicking it.

you need have span outside link , positioned on top of link.

i don't know full html & css have in place need wrap link , span this:

* {    box-sizing: border-box;  }  .wrap {    display: inline-block;    border: 2px solid green;    position: relative;  }  {    display: block;    background: plum;    text-decoration: none;    font-weight: bold;    padding: .25em;    color: red;  }  .link-settings {    position: absolute;    height: 100%;    right: 0;    top: 0;    background: grey;    color: white;    font-weight: bold;    padding: .25em;    display: none;  }  .wrap:hover .link-settings {    display: block;  }
<div class="wrap">    <a href="#">lorem ipsum dolor sit amet.</a>    <span class="link-settings">icon</span>  </<div>


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -