I am attempting to modify the CSS of 2 ASP controls using jQuery specifically for users accessing the site with Internet Explorer 10 or 11. This adjustment is necessary because IE10 onwards, conditional comments are no longer supported. My approach to achieving this is as follows:
<script>
$(document).ready(function () {
if ($.browser.msie && $.browser.version === 10 || $.browser.msie && $.browser.version === 11) {
alert('testIf');
$("#txtUsername").removeAttr('loginInput');
$("#txtPassword").removeAttr('loginInput');
$("#txtUsername").css({
"width": "284px",
"border": "0px",
"border-top": "1px solid #646464",
"border-bottom": "0px #646464 solid",
"border-left": "solid #646464 4px",
"height": "33px",
"background-image": "url(./Images/login-icon.png)",
"background-repeat": "no-repeat",
"padding-left": "16px",
"float": "left",
"display": "block",
});
$("#txtPassword").css({
"width": "284px",
"border": "0px",
"border-top": "1px solid #646464",
"border-bottom": "0px #646464 solid",
"border-left": "solid #646464 4px",
"height": "33px",
"background-image": "url(./Images/login-icon.png)",
"background-repeat": "no-repeat",
"padding-left": "16px",
"float": "left",
"display": "block",
});
} else {
alert('testElse');
}
});
</script>
I have implemented 2 textboxes like so:
<asp:TextBox CssClass="loginInput loginUsername" TabIndex="1" ID="txtUsername" autocomplete="off" AutoCompleteType="Disabled" runat="server"></asp:TextBox>
<asp:TextBox CssClass="loginInput loginPassword" TabIndex="2" ID="txtPassword" textmode="Password" runat="server"></asp:TextBox>
This is my modified CSS (with width being the only change from the original):
.loginInput {
width: 285px;
border: 0px;
border-top: 1px solid #646464;
border-bottom: 0px #646464 solid;
border-left: solid #646464 4px;
height: 33px;
background-image: url(./Images/login-icon.png);
background-repeat: no-repeat;
padding-left: 16px;
float:left;
display:block;
}
.loginUsername {
margin-top: 15px;
background-position: 271px 9px;
}
.loginPassword {
background-position: 271px -75px;
}
In Internet Explorer, the only necessary modification is altering the width for the CSS to display correctly. I've attempted moving the JS outside the document ready function but to no avail. Could someone provide guidance on what I might be doing incorrectly and suggest a way forward.