大牛们帮忙看一个问题

shenlei_water 2011-07-29 08:24:26
我给input添加了一个事件 代码如下

<input id="Content1" type="text" size="25" value="讲座" class="bordertext" onClick="divId('Content1')" onfocus="blurInput('Content1')" />

但是在页面加载以后
onfocus function() { this.className = focusClass; }


而 onclick function onclick(event) {divId('Content1')}

正常

这个onfocus 事件发生这样的变化是为什么啊?
...全文
101 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
MuBeiBei 2011-07-29
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 shenlei_water 的回复:]
我自己写了一个测试案例也是好的 但是在页面中就出现这个问题
[/Quote]

把代码发个全的上来~·
shenlei_water 2011-07-29
  • 打赏
  • 举报
回复
我自己写了一个测试案例也是好的 但是在页面中就出现这个问题
MuBeiBei 2011-07-29
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<input id="Content1" type="text" size="25" value="讲座" class="bordertext" onClick="divId('Content1')" onfocus="blurInput('Content1')" />

<script>
function blurInput(id){
document.getElementById(id).className = focusClass;
}
</script>
</body>
</html>


这样也行
MuBeiBei 2011-07-29
  • 打赏
  • 举报
回复
onfocus="blurInput(this)"
shenlei_water 2011-07-29
  • 打赏
  • 举报
回复
那要怎么改啊?
MuBeiBei 2011-07-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 shenlei_water 的回复:]
我写的是这样的
onfocus="blurInput('Content1')"

这个是
onfocus function() { this.className = focusClass; }

页面加载后我在IE调试工具下看到的 onfocus 事件 为什么和我写的不一样啊?
[/Quote]

我写的是这样的
onfocus="blurInput('Content1')"
你这么写找不到this,当前事件对象
shenlei_water 2011-07-29
  • 打赏
  • 举报
回复
我写的是这样的
onfocus="blurInput('Content1')"

这个是
onfocus function() { this.className = focusClass; }

页面加载后我在IE调试工具下看到的 onfocus 事件 为什么和我写的不一样啊?
挨踢直男 2011-07-29
  • 打赏
  • 举报
回复
onfocus function() { this.className = focusClass; }
不能用this

<input id="Content1" type="text" size="25" value="讲座" class="bordertext" onClick="divId('Content1')" onfocus="blurInput(this)" />
function blurInput(o)
{
o.className = focusClass
}
ZYLBLCU 2011-07-29
  • 打赏
  • 举报
回复
楼上有解~

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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