jquery input 文本选中的问题

awanghjun 2012-08-08 11:37:58
我想点击input选中里面的value,再点一下可以编辑

function oldUserBuyClick(){
var customer = $(this);
customer.select()
}

可在ie下点击input一直处在选中状态,除非都删了。
请高手指点下

用过unbind("click"), 不好使
...全文
1478 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
一笔走天涯 2013-10-17
  • 打赏
  • 举报
回复
如何选择标签span中的文本了,类似input标签的select效果?
joybee007 2012-08-08
  • 打赏
  • 举报
回复
function oldUserBuyClick(){
var customer = document.getElementById('input');
customer.select()
}
这个地方做个判断,
function oldUserBuyClick(){
var customer = document.getElementById('input');
if(!this.selected){
customer.select();
this.selected=true;
}else{
this.selected=false;
}
awanghjun 2012-08-08
  • 打赏
  • 举报
回复
不是想让他不能编辑,我想问的是怎么让他点击第一下选中,第二下不选中?
[Quote=引用 3 楼 的回复:]

设个全局变量,第一次点击设置readonly属性 ;第二次移除readonly属性
[/Quote]
gf05011 2012-08-08
  • 打赏
  • 举报
回复
设个全局变量,第一次点击设置readonly属性 ;第二次移除readonly属性
awanghjun 2012-08-08
  • 打赏
  • 举报
回复
我重新发个html吧
这个不直观

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题</title>
</head>
<body>
<input type="text" name="" value="" id="input" onclick="oldUserBuyClick()">
<script type="text/javascript" language="javascript" >

function oldUserBuyClick(){
var customer = document.getElementById('input');
customer.select()
}
</script>
</body>
</html>
我就是大神 2012-08-08
  • 打赏
  • 举报
回复
代码有问题吧,this是谁呢?,你得传参数吧
awanghjun 2012-08-08
  • 打赏
  • 举报
回复
高手!原来事情想复杂也不好~谢谢

[Quote=引用 6 楼 的回复:]

不要想得太复杂了。HTML code
<input type="text" name="" value="123" id="input" onfocus="this.select()" />
[/Quote]
persuit666 2012-08-08
  • 打赏
  • 举报
回复
要编辑文本框必须聚焦,这点认同6楼!必须还得focus
scscms太阳光 2012-08-08
  • 打赏
  • 举报
回复
不要想得太复杂了。
<input type="text" name="" value="123" id="input" onfocus="this.select()" />

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧