Reputation: 6295
input[type="text"]:focus{
border:solid 2px red;
}
If i was to use the above CSS rule it would not work in IE6,it just sort of disables the text control.I know the CSS bit can be taken care of using a conditional comment.Now I understand that to get the border to change in IE6 I have to use javascript or jQuery. My question is does a conditional comment similar to CSS exist for java script that binds the function that changes the border to the control only if the browser is IE6? Because modern browsers wont be needing this code.Hope I'm making some sense.
Upvotes: 0
Views: 491
Reputation: 4203
There is no selector that can do this for IE6, if you absolutely must support this feature you will have to use the help of javascript. Put this function on your page:
function appendInputTypeClasses() {
if (!document.getElementsByTagName )
return;
var inputs = document.getElementsByTagName('input');
var inputLen = inputs.length;
for ( i=0;i<inputLen;i++ ) {
if ( inputs[i].getAttribute('type') )
inputs[i].className += ' '+inputs[i].getAttribute('type');
}
}
This will add the type of the input to the class, so you can use:
input[type='text'],input.text
input[type='radio'],input.radio
input[type='checkbox'],input.checkbox
Upvotes: 0
Reputation: 43243
Have you tried using ie7js, ie8js or ie9js?
http://code.google.com/p/ie7-js/
This would in my opinion be the optimal way to solve this, as you simply include the appropriate script on your page, and it automagically fixes certain features for you.
Upvotes: 0
Reputation: 146302
Just do the same thing:
<!--[if lte IE 6]>
<script type='text/javascript'>
// IE JAVASCRIPT HERE
</script>
<![endif]-->
Upvotes: 3