我想点击后更改背景颜色? [英] i want to change the background color after clicking?

查看:86
本文介绍了我想点击后更改背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在点击后更改背景颜色

I want to change the background color after clicking

这是我的HTML代码

<td class="meun" onclick="getclick();">...</td>

这是我的JavaScript:

And this is my JavaScript:

function getclick()
{
    this.style.background-color: #EFF2F7;
}

http://jsfiddle.net/3ZmCh/

我想当在表格中的 td 中点击任何一个以更改其背景颜色

i want when click any on in the td in the table to change it's background color

推荐答案

http://jsfiddle.net/ThiefMaster/3ZmCh/16/

您需要传递这个作为参数,并在处理程序方法中使用正确的JavaScript:

You need to pass this as an argument and use proper JavaScript in the handler method:

function getclick(elem) {
    elem.style.backgroundColor = '#EFF2F7';
}

这篇关于我想点击后更改背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆