Use javascript to click on a pseudo-element?

前端 未结 5 1501
栀梦
栀梦 2020-12-03 14:37

I\'m wondering how to enable the clicking on a :before pseudo-element (the orange part of the div on the JSfiddle I link to below). I\'ve read that since pseudo

5条回答
  •  不思量自难忘°
    2020-12-03 14:59

    I know you are trying to use :before, but for this situation, can't you just create a new div with a class to use as a hook and append it to the original div?

    Something like this might work:

    var newDiv = $("
    "); $(".parentDivToOrangeCircle").append(newDiv);

    And the CSS:

    .parentDivToOrangeCircle { position:relative; background-color:#333;
        padding:20px; margin:20px; float:left; 
    }
    
    .orangeCircle {
        padding:5px; background-color:#f60; border:2px solid white; 
        position: absolute; top:-2px; right:-2px; border-bottom-left-radius: 10px; 
    }
    

提交回复
热议问题