可以加一个id 或者 直接给个style 我是这样写的setAttribute("style","outline:"+color+" dashed 2px;") 但不知道要怎么 点击按钮时把样式删除。
解决方案 »
- 急求js实现下载功能问题
- 当鼠标划过一个图片时候 这个图片的id值就改变 怎么写?着急
- 这个问题如何解决呢?
- 怎么实现像msn spaces里随意拖动自动调整大小的功能
- 如何用js取消浏览器的表单提示
- 两个frame对应同一个form,怎么知道当前操作的form是属于哪一个frame的
- 怎样用JS去掉Select中的onchange,急.................................
- 跨页面的javascript的调用问题.
- 如何在邮件中增加一些特效
- 如何使页面上的某元素在页面上居中
- 我想修改一个jqeruy插件jeditable,但是有的地方不是很理解,请教一下大家。
- JS能调用vba对象的事件吗
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
</head>
<body>
<div id="test" style="border:1px solid red;">123</div>
<button id="btn">click</button>
<script>
function $(el){
return typeof el == 'string' ? document.getElementById(el) : el;
}
function $t(name, cot){
cot = cot || document;
return cot.getElementsByTagName(name);
}
$('btn').onclick = function(){
$('test').removeAttribute('style');
}
</script>
</body>
</html>
这个意思?
<script type="text/javascript">
document.getElementById('demo').style.outline = '2px dashed red'; //添加
document.getElementById('demo').style.outline = ''; //删除
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
</head>
<body>
<div id="test" style="border:1px solid red; color:red; font-size:123px;">123</div>
<button id="btn">click</button>
<script>
function $(el){
return typeof el == 'string' ? document.getElementById(el) : el;
}
function removeStyle(obj, name){
if(!name) {
obj.removeAttribute('style');
return obj;
}
var s = obj.style;
if(s.removeAttribute){
s.removeAttribute(name);
} else {
name = name.replace(/([A-Z])/g, function(v){
return '-' + v.toLowerCase();
});
s.removeProperty(name);
}
return obj;
}
$('btn').onclick = function(){
removeStyle($('test'), 'fontSize')
}
</script>
</body>
</html>楼主这个 意思?
ie下 删除border不友好,
可以 换成 对class进行操作,类似于addClass removeClass 楼主再看看。
我想把zheng-ze-biao-da-shi ss 中的”zheng-ze-biao-da-shi空格“去掉。一个的我回两个的怎么弄。
<html>
<head>
<meta charset="gb2312" />
<title></title>
</head>
<body>
<a class="zheng-ze-biao-da-shi ss" href="#" tag="reg" id="test">sdfsdf</a>
<script>
function $(el){
return typeof el == 'string' ? document.getElementById(el) : el;
}
$('test').className = $('test').className.split(' ')[1];
</script>
</body>
</html>