//error.js代码
function changepicture( id, cls ) {
var obj = document.getElementById( id );
if (obj) {
if (cls == '1') {
obj.className = "state1";
//alert("");
} else {
obj.className = "state2";
//alert("");
}
}
}
function showorhidediv( id ) {
var obj = document.getElementById( id );
if (obj) {
if (obj.style.display == 'block') {
obj.style.display = 'none';
changepicture(id.toString().replace('result', 'title'), '1');
} else {
obj.style.display = 'block';
changepicture(id.toString().replace('result', 'title'), '2');
}
}
}//test.css
.state1{padding: 0px 0 0 12px; background:url(../img/show_01.png) no-repeat; background-position: 0 52%;}//+图片
.state2{padding: 0px 0 0 12px; background:url(../img/show_02.png) no-repeat; background-position: 0 52%;}//-图片
//调用test.html
<a href="javascript:void(0);" onFocus="this.blur()" onclick="javascript:showorhidediv('ie_act_result');" >
<span id="ie_act_title" class="state1">IE Activity Traces</span>
</a>
上述代码是为了实现:点击<a>元素,切换其背景。
但是,现在没有得到想要的结果.点击+后背景没有切换成-号的背景。但当加上//alert(""); 后,-后图片正常切换.
请高手指点下。
function changepicture( id, cls ) {
var obj = document.getElementById( id );
if (obj) {
if (cls == '1') {
obj.className = "state1";
//alert("");
} else {
obj.className = "state2";
//alert("");
}
}
}
function showorhidediv( id ) {
var obj = document.getElementById( id );
if (obj) {
if (obj.style.display == 'block') {
obj.style.display = 'none';
changepicture(id.toString().replace('result', 'title'), '1');
} else {
obj.style.display = 'block';
changepicture(id.toString().replace('result', 'title'), '2');
}
}
}//test.css
.state1{padding: 0px 0 0 12px; background:url(../img/show_01.png) no-repeat; background-position: 0 52%;}//+图片
.state2{padding: 0px 0 0 12px; background:url(../img/show_02.png) no-repeat; background-position: 0 52%;}//-图片
//调用test.html
<a href="javascript:void(0);" onFocus="this.blur()" onclick="javascript:showorhidediv('ie_act_result');" >
<span id="ie_act_title" class="state1">IE Activity Traces</span>
</a>
上述代码是为了实现:点击<a>元素,切换其背景。
但是,现在没有得到想要的结果.点击+后背景没有切换成-号的背景。但当加上//alert(""); 后,-后图片正常切换.
请高手指点下。
解决方案 »
- 明眼人一看就明白,为什么的Jplayer放不了mp3文件,写错了吗
- !!求正则表达式!高分求一去重复数字串的正则表达式,在线等;请高手帮忙;
- jquery ajax 返回值的问题,急求解决!
- 我写了个在浏览器输出星期几的javascript代码出了什么问题?
- 求助:split可以嵌套么?怎么用阿
- 关于onbeforeunload的问题
- 根据radio不同选定触发事件使一个文本框是否显示
- 菜鸟求一验证函数
- 关于框架关闭的问题·急!!!!!!!
- 你好!请问一下在脚本中如何控制<A href="c:" id=aa target="_top"></a>的连接执行呢?---十分急~
- 在火狐下的document.getElementById(id)的问题;
- EXT显示数据问题
你的这样的写法,很负责,而且效果也不好。。如果你是说span 鼠标放上去没有鼠标手势的话,可以试试这个css属性 <span id="ie_act_title" class="state1" style='cursor:point'>IE Activity Traces</span>
然后再这个标签加上事件来直接切换标签的CSS
最简单就是使用jquery $("#ie_act_title").attr("class","state2");