I am trying to change the css of 2 ASP controls using jQuery when the user uses Internet Explorer 10 or 11. I need to do this because after IE10 they stopped using conditional comments. Now, I what I try to do is this:
<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 2 textboxes like this:
<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 CSS (the only change with the css above is the width):
.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 Explore I only need to change the width so that my css looks right, I tried to put the JS out the document ready function but that also does not work. Can anyone help me out here, tell me what I do wrong and what I should do next.