rainliu 发表于 2013-1-29 07:29:16

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

(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\" 不能用单引号。
(4)js换class样式
form.firstPage.className='button_first2';
delItems.className='button_searchdel';
注:要用className用class属性调用不到的
 
完全控制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')">
页: [1]
查看完整版本: input button按钮设置背景图,自动生成调用class 和js换class样式 完全控制input的样式