实例 触发选定元素的 select 事件

x
 
<!DOCTYPE html>
<html>
<head>
<script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("input").select(function(){
    $("input").after(" Text marked!");
  });
});
</script>
</head>
<body>
<input type="text" value="Hello World">
<p>Select some text inside the input field.</p>
</body>
</html>
                    

输出结果