當前端頁面遇到不能改變輸入框等各種框的長短屬性時解決的方法
阿新 • • 發佈:2018-12-23
1.用cssClass屬性
//加入cssClass="tree"屬性 <label class="control-label">區域:</label> <div class="controls" > //樹 <sys:treeselect id="area" name="countryArea.id" value="${projectInfo.countryArea.id}" labelName="countryArea.name" labelValue="${projectInfo.countryArea.name}" title="Country&Area" url="/delivery/area/treeData" expandAll="true" cssClass="tree"allowClear="true" /> //加上一個標記 <span class="help-inline"><font color="red">*</font> </span> </div>
2. 用.css("width","130px");
getSelect函式: function getSelect(name,items,key,value,changeFunctionName){ var select = $("<select ></select>"); if(name){ select.attr("name",name); } if(changeFunctionName){ select.attr("onchange",changeFunctionName+"()"); } var emptyOption = $("<option></option>").val("").text("-select-"); select.append(emptyOption); for(itemKey in items){ var option = $("<option></option>").val(items[itemKey][value]).text(items[itemKey][key]); select.append(option); } return select; }
呼叫getSelect並且設定屬性:
var HSListSelect = getSelect("",reiHSList,"name","id"); HSListSelect.css("width","130px");