3
I made a code that should generate several inputs
:
var n = document.getElementById("numeroCamadas").value
var ttt;
var layers = {}
for (var i =0; i<n; i++){
layers["layer" + i] = {
'espessura':0 ,
'altura':0 ,
'pesoEspecifico':0,
'tensaoHorizontal':0,
'poroPressao':0,
'tensaoTotal':0,
'tensaoTotalMeio':0,
'tensaoTotalEfetiva':0,
'tensaoTotalEfetivaMeio':0};
ttt +="<li class=\"ui-field-contain\">"
+"<h5>Camada "+(i+1)+"</h5>"
+"<div style=\"float:left; width:30%;\">"
+"<input type=\"number\" placeholder=\"Altura"+(i+1) +"\" value=\"\" id=\"altura"+(i+1) +"\" onfocusout=\"tensao()\">"
+"</div>"
+"<div style=\"float:left; width:30%;\">"
+"<input type=\"number\" placeholder=\"Peso Especifico"+(i+1) +"\" value=\"\" id=\"pesoEspecifico"+(i+1) +"\" onfocusout=\"tensao()\">"
+"</div>"
+"<div style=\"float:left; width:30%;\">"
+"<input type=\"number\" placeholder=\"Tensão Horizontal"+(i+1) +"\" value=\"\" id=\"geraCamadasHorizontal"+(i+1) +"\" onfocusout=\"tensao()\">"
+"</div>"
+"<br>"
+"<li>Espessura da Camada:<b id=\"espessuraCamada"+(i+1) +"\"></b></li>"
+"<li>Tensão Total:<b id=\"uMedia\"></b></li>"
+"<li>Tensão Efetiva:<b id=\"fc\"></b></li><br>"
+"</li>"
}
document.getElementById("camadas").innerHTML=ttt
}
The code works, but everything it generates doesn’t come with CSS, which is the CSS of jquery.mobile-1.4.5.min.css
.
Is there a function to reject CSS or something like that???
I’ve been advised to do this:
$(".ui-field-contain").css("border-bottom-width","1px");
$(".ui-field-contain").css("border-bottom-right-radius","inherit");
$(".ui-field-contain").css("border-bottom-left-radius","inherit");
$(".ui-field-contain").css("border-top-left-radius","inherit");
$(".ui-field-contain").css("padding","0.7em 1em");
$(".ui-field-contain").css("border-right-width","1px");
$(".ui-field-contain").css("border-left-width","1px");
$(".ui-field-contain").css("border-width","1px 0 0");
$(".ui-field-contain").css("border-style","solid");
$(".ui-field-contain").css("margin","0");
$(".ui-field-contain").css("display","block");
$(".ui-field-contain").css("position","relative");
$(".ui-field-contain").css("text-align","left");
$(".ui-field-contain").css("text-overflow","ellipsis");
$(".ui-field-contain").css("overflow","hidden");
$(".ui-field-contain").css("white-space","nowrap");
$(".ui-field-contain").css("background-color","white");
$(".ui-field-contain").css("border-color","#ddd");
$(".ui-field-contain").css("color","#333");
$(".ui-field-contain").css("text-shadow","0 1px 0 #f3f3f3");
$("input").css( "margin" , "0" );
$("input").css( "min-height" , "2.2em" );
$("input").css( "text-align" , "left" );
$("input").css( "border-radius" , "5px" );
$("input").css( "background" , "transparent none" );
$("input").css( "line-height" , "1.4em" );
$("input").css( "display" , "block" );
$("input").css( "width" , "auto" );
$("input").css( "box-sizing" , "border-box" );
$("input").css( "outline" , "0" );
$("input").css( "color" , "inherit" );
$("input").css( "text-shadow" , "inherit" );
$("input").css( "font-size" , "1em" );
$("input").css( "font-family" , "sans-serif" );
$("#cfc").css( "margin-left" , "5em" );
But it’s a lot of work, and it’s not giving a good result.
Follow index as requested
Soil Stresses
Menu<div role="main" class="ui-content">
<ul data-role="listview" data-inset="true">
<li class="ui-field-contain">
<label style="width:3em; float:left;">Número de Camadas</label>
<div style="float:right; width:30%;">
<input type="number" value="2" id="numeroCamadas" onfocusout="()">
<button onclick="geraCamadas()">Gerar Camadas</button>
</div>
</li>
</ul>
<ul data-role="listview" data-inset="true" id="camadas">
<li class="ui-field-contain">
<h5>Camada 1</h5>
<div id="cfc" style="float:left; width:30%;">
<input type="number" placeholder="Altura" value="" id="altura1" id="put" onfocusout="">
</div>
<div id="cfc" style="float:left; margin-left: 0.5em; width:30%;">
<input type="number" placeholder="Peso Espeçifico" value="" id="PesoEspecifico1" onfocusout="tensao()">
</div>
<div id="cfc" style="float:left; margin-left: 0.5em; width:30%;">
<input type="number" placeholder="Tensão Horizontal" value="" id="TensaoHorizontal" onfocusout="tensao()">
</div><br>
</li>
<li>Umidade média:<b id="uMedia"></b></li>
<li>Fator Correção:<b id="fc"></b></li>
</ul>
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
</body>
I strongly advise against doing this... CSS should work even for elements added later. The problem has to be elsewhere. You can add the HTML you have?
– Sergio
Insert the index
– Jacob Athias
Can you modify this jsFiddle to show your problem? -> http://jsfiddle.net/f108qwc2/
– Sergio
I did everything to make it work in the fiddle, but there is worse, not loaded anything, not css, not my javascript funf
– Jacob Athias
I don’t know how jquery-mobile works. But does it not use classes for that? Otherwise it would just be assigning classes instead of style by style.
– GilCarvalhoDev
You should solve this by adding classes to the HTML elements
– Guilherme Souza
Seeing this question Forcing jQuery Mobile to re-evaluate Styles/Theme on dynamically inserted content, maybe you just need to make one
$("#camadas").trigger("create")
.– Tobias Mesquita