I need to manipulate an attribute of an html tag that was loaded dynamically through ajax. I've tried it in many ways using jQuery but none of it worked.
The code being loaded via ajax is as follows:
<table cellspacing="0" cellpadding="0" id="idTablePhoneFC" style="max-width: 480px;">
<tbody>
<tr>
<td class="EstChkValorCampo">
<input type="text" onchange="F$.fnCleanErrField('P2Telefone');" style="width:100px" maxlength="20" size="10" value="" id="P2Telefone" name="P2Telefone" class="InputText"><span></span>
</td>
</tr>
</tbody>
</table>
Note that the input[type=text]
field has the "style" attribute forcing a maximum width of 100px.
I tried to use CSS! Important to try to force the element to get a wider width than that, but it is not accepting.
So my idea was to try using jquery, but I did not get results with the following code:
<script>
$(function() {
$("#P2Telefone").css('width','100%');
$(window).bind('load',function(){
$("#P2Telefone").css('width','100%');
});
$(window).load(function() {
$("#P2Telefone").css('width','100%');
});
$(window).on("load",function(){
$("#P2Telefone").css('width','100%');
});
});
</script>
Does anyone have any idea how to solve this?