CSS attribute selector bug in IE8?

2019-07-20 18:50发布

as specified by CSS 2.1:

input[type=submit] {
}

or

input[type="submit"] {
}

must matches any input element whose "type" attribute value is exactly equal to "submit". However this selector doesn't works on IE8 (and IE7 compatibility mode). Any hint? workarounds?

4条回答
Rolldiameter
2楼-- · 2019-07-20 19:25

internet explorer doesn't retroactively apply styles though.

and the use of those jquery selectors only applies to elements present before that code is run.

anything created and inserted into the DOM afterwards won't be affected by that code.

查看更多
干净又极端
3楼-- · 2019-07-20 19:25

To answer to your post’s title —not precisely your case—, I’ve just experiment a bug on IE8 :

I was working on the integration of an ASP.net project where pages names starts by a capital…

and…

WITH THIS FORM

<form name="aspnetForm" method="post" action="Default.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">

Internet Explorer 8 distinguish

form[action^="Default"]

Value : Default → don’t work (but work on IE11 and modern browsers…)

and

form[action^="default"]

Value : default → WORK

查看更多
看我几分像从前
4楼-- · 2019-07-20 19:27

you can use input[type='submit'] { code here... } hopefully this is working in IE as well as older IE.

查看更多
乱世女痞
5楼-- · 2019-07-20 19:34

jQuery will give you the selectors you need without dirty hacks.

$(':submit').css( 'styleprop', 'value' );

Example:

$(':submit').css('color','red');
查看更多
登录 后发表回答