本文介绍了使用javascript为innerhtml中存在的组件添加CSS样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将css样式添加到javascript页面plzzzz帮助我并提前感谢
I would like to add css style to javascript page plzzzz help me and thanks in advance
document.getElementById('tdMilestoneHeader').innerHTML = '<div class="TitleCss1"><table style="width:93%;color: #1a4381;font-weight: bolder;font-family:Calibri; font-size:medium"><tr><td align="left">'+
'<label style="font-family:Calibri;font-weight:800;font-size:19" > Show me my </label> ' +
'<select id="FilterSelection" onchange="combobox()" style="font-family:Calibri;font-weight:800;font-size:17;background-color:#B7DBFF; width:139px; ForeColor:#003399; color:#003399"> <option value="liabilities">Liabilities</option><option value="plan">Plan</option></select> ' +
'<label style="font-family:Calibri;font-weight:800;font-size:19" > for </label> ' +
'<select id="PeriodSelection" onchange="combobox()" style="font-family:Calibri;font-weight:800;font-size:17;background-color:#B7DBFF; width:139px; ForeColor:#003399; color:#003399"> <option value="currentweek">Current Week</option><option value="nextweek">Next Week</option><option value="currentmonth">Current Month</option><option value="nextmonth">Next Month</option><option value="allperiods">All Period</option></select> ' +
'<label id="thTotal" style="font-family:Calibri;font-weight:800;font-size:19">Total-' + BugCount + '</label> ' +
'<label id="thTotal" style="font-family:Calibri;font-weight:800;font-size:19">(' + dateheader +')</label></td></td>' +
'<td align="right" valign="top" ><img src="../TaskManager/images/excel.png" onclick="OnExport2ExcelClick();" title="Export to excel."style="cursor: hand; height: 22px; width: 25px; vertical-align:top;" /></td></tr><table></div>';
这是我的javascript页面
This is my javascript page
<style>
.select{
border:1px solid #ccc;
overflow:hidden;
background:url('../Images/h_expand.gif') no-repeat 95% 50%;
}
.select::-ms-expand {
display: none;
}
</style>
这是Html
页面中的样式
我想将此样式添加到innerhtml中的select选项框中我无法将此选项放在html页面中,因为它位于master page.so中作为innerhtml插入。是否有可能添加样式类?
This is the style in Html page
I would like to add this style to the select option box present in the innerhtml I couldnt place this select option in html page because it is in master page.so inserted as innerhtml. Is there any possibility to add style class?
推荐答案
<select class="select" ....
这篇关于使用javascript为innerhtml中存在的组件添加CSS样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!