如何在单选框选中的情况下,使选项的图标点亮;而其他没有选中的呈灰色。求JS代码.
解决方案 »
- 求一时间正则表达式~~~~~~~~~~~~~~马上揭帖~~
- 为什么不能调用 P()函数,显示 “PPPPPPPPP”讲讲为什么??
- 暴难问题啊,救命啊,表的一对多关系,如何取得动态加入的文本框的值!!!!!!!!!!!!!!!!
- 求助,格式化日期???在线等。。。
- 在同一页面内只刷新table,脚本?请指点
- 急,请教以下代码什么意思?
- window.opener.href="..."这句话为什么不能正确执行?
- Js取值问题
- 情大虾指教
- HOT~网页中调用reallpayer插件,能不能自己定义风格啊?谁能告诉我插件的参数及其含义?
- 一个JS小问题
- 请问一下,现在Extjs 现在是什么版本?如果有发一下给我
<!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>
<script type="text/javascript" src="http://www.wanmei.com/public/js/jq_132.js"></script>
<style>
span{width:100px; background:}
</style>
</head><body>
<input type="checkbox" value="1" /><span>1</span><br />
<input type="checkbox" value="2" /><span>2</span><br />
<input type="checkbox" value="3" /><span>3</span><br />
<script>
var inps = document.getElementsByTagName('input'),
len = inps.length,
spans = document.getElementsByTagName('span');
for(var i = 0; i < len; i++){
!function(i){
inps[i].onclick = function(){
if(this.checked){
spans[i].style.background = '#333';
}else{
spans[i].style.background = '';
}
};
}(i)
}
</script>
</body>
</html>
给你个例子,如果你前面是图标的话,就做出来两个图,一个是亮的一个是不亮的。
然后改变图片的src属性就行了~·
<!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>
<script type="text/javascript" src="http://www.wanmei.com/public/js/jq_132.js"></script>
<style>
span{width:100px; background:}
</style>
</head><body>
<input type="radio" value="1" name="a" /><span>1</span><br />
<input type="radio" value="2" name="a" /><span>2</span><br />
<input type="radio" value="3" name="a" /><span>3</span><br />
<script>
var inps = document.getElementsByTagName('input'),
len = inps.length,
spans = document.getElementsByTagName('span');
for(var i = 0; i < len; i++){
!function(i){
inps[i].onclick = function(){
for(var j = 0; j < spans.length; j++){
spans[j].style.background = '';
}
if(this.checked){
spans[i].style.background = '#333';
}
};
}(i)
}
</script>
</body>
</html>
你得改变图片的src地址~·
<!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>
<script type="text/javascript" src="http://www.wanmei.com/public/js/jq_132.js"></script>
<style>
span{width:100px; background:}
</style>
</head><body>
<input type="radio" value="1" name="a" /><img src="1.jpg" /><br />
<input type="radio" value="2" name="a" /><img src="1.jpg" /><br />
<input type="radio" value="3" name="a" /><img src="1.jpg" /><br />
<script>
var inps = document.getElementsByTagName('input'),
len = inps.length,
imgs = document.getElementsByTagName('img');
for(var i = 0; i < len; i++){
!function(i){
inps[i].onclick = function(){
for(var j = 0; j < imgs.length; j++){
imgs[j].src = '1.jpg'; //这里写不亮的图标地址
}
if(this.checked){
imgs[i].src = '2.jpg';//在这写亮的那个图标
}
};
}(i)
}
</script>
</body>
</html>