click 点击事件触发,select 事件执行多次
分析:触发了事件的默认行为
解决1:
$(document).ready(function(){
$("input").select(function(event){
event.preventDefault();
$("input").after("文本已选中!");
});
$("button").click(function(){
$("input").select();
});
});
解决2:
$(document).ready(function(){
$("input").select(function(){
$("input").after("文本已选中!");
return false;
});
$("button").click(function(){
$("input").select();
});
});
解决3:
$(document).ready(function(){
$("input").select(function(){
$("input").after("文本已选中!");
});
$("button").click(function(){
$("input").triggerHandler("select");
});
});