内容后无法选择

时间:2015-10-28 23:29:24

标签: jquery

请您看看这个演示,让我知道为什么我无法选择后续内容

$("#yellow::after").on("click", function(){
    alert("The after was clicked.");
});
div{background:yellow; height:200px; width:200px; margin-left:-210px;}
div::after {
  content: "Content";
    background-color:red;
   margin-left:200px;
    
    padding:15px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="yellow">
  hi
</div>

1 个答案:

答案 0 :(得分:1)

试试这个:

$("#yellow").after().on("click", function(){
alert("The after was clicked.");
});

示例:http://jsfiddle.net/Lx65bwzt/1/