六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 114|回复: 0

input button按钮设置背景图,自动生成调用class 和js换class样式 完全控制input的样式

[复制链接]

升级  50%

5

主题

5

主题

5

主题

童生

Rank: 1

积分
25
 楼主| 发表于 2013-1-29 07:29:16 | 显示全部楼层 |阅读模式
1)直接在input里面加个class属性
                                          <td width="0" style="WIDTH: 100%" ><input class="button_searchdel2" type="button" name="delItem" value="  " style="WIDTH: 30px"  disabled></td>
2)对应css里面定义一个样式
.button_searchdel2
{
font-size: 12px; background: url(../images/gridform/searchdel2.gif); border: 0px; width: 30px; height: 24px;
}
3)自动生成调用样式
sbhead.append("<td class=\" button_searchdel2\" style='cursor: default;" + strMyHide

                  + "'  valign=middle  onclick=\"orderdo('" + strColumName

                  + "');return false;\" title=\"单击此列,系统将按 [" + tem

                  + "] 排序\"  >" + tem + "</td>");
注:java里面要用class=\" button_searchdel2\" 不能用单引号。
4jsclass样式
form.firstPage.className='button_first2';
delItems[delItems.length -1].className='button_searchdel';
注:要用classNameclass属性调用不到的
 
完全控制input的样式,这个样式控制到了高宽和里面文字显示位置居中
.input {
BACKGROUND: url(../../images/login/input.gif) #ffffff no-repeat left top; VERTICAL-ALIGN: middle;font-size: 12px;HEIGHT: 20px;width: 140px;padding-top: 2px;padding-bottom: 2px;

border:1px solid #000;
}
对应页面的input :<input class="input" onblur=showBlur(this) onfocus=showFocus(this) size=21
                  maxlength=20 id="userName" name="userName" onkeydown="keyDownMoveFocus('passWord')">

您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表