English 中文(简体)
j Query Problem with IE ...... still work on « &key
原标题:jQuery Problem with IE ... still works on Firefox & Chrome

got a little problem with IE8 ...

《刑法》第2版和第4版。

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("[title="CAPPL:LOCAL.L_hk[1].vorlauftemp_ist-shortText"]").css("background-     color","red");
});
</script>
</head>
<body>
<div title="CAPPL:LOCAL.L_hk[1].vorlauftemp_ist-shortText">Value</div>
</body>
</html>

If i want to use this Code in IE8 or below it crashes without any error message ... Does anybody has a solution for this tricky problem?

P.S. to uninstall IE8 is noooo solution :D

最佳回答
$(document).ready(function() {
  $("[title=CAPPL\:LOCAL\.L_hk\[1\]\.vorlauftemp_ist-shortText]").css({"background-color" : "red"});
});

it seems IE7/IE8 compatibility mode still needs the special characters in the attribute value escaped using double backslashes. also note it works without escaping the _ and the quotes before and after the title are not required

http://api.jquery.com/ category/selectors/“rel=“nofollow”>jquery docs

If you wish to use any of the meta-characters ( such as !"#$%& ()*+,./:;<=>?@[]^{|}~ ) as a literal part of a name, you must escape the character with two backslashes: \. For example, if you have an element with id="foo.bar", you can use the selector $("#foo\.bar"). The W3C CSS specification contains the complete set of rules regarding valid CSS selectors.

问题回答

IE问题是具有方括号的组合,在挑选人中具有殖民地。

在IE(无:或[]):。 http://jsfiddle.net/aM9nX/4/

http://jsfiddle.net/4nfHW/1/"rel=“nofollow”http://jsfiddle.net/4nfHW/1/

This fiddle does not (has : and []): http://jsfiddle.net/xghtg/3/

Is it possible for you to remove those characters?

try .css({"background-color","red"}) I dont know if thats the issue but its caused me grief before ( were missing the {s )

Not sure if it s a typo, but the spaces in "background- color" will cause it not to work.

@anothershrubery is right.. it does work in IE8 http://jsfiddle.net/ha44p/

you misspelled the css property background-color, that seems to be the problem.

It is perfectly working on FF, Safari, Chrome, IE9, IE8, except on IE7.

See for yourself. 我改为“。 更恰当地感谢它。

http://jsfiddle.net/p2ReV/"rel=“nofollow> http://jsfiddle.net/p2ReV/





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Private FireFox plugin

I m looking at getting a FireFox plugin developed - but is it possible to create a plugin that is for private use only, so only those I share it with have it and not open to the masses? Need this for ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Cross-browser development

I m developing a web application for a new service, starting from Firefox 3.5. The interface design is tableless, only using divs + CSS & performance-blessed practices. Now, while being ...

Cross browser way of setting IFrame to "about:blank"?

Does anybody know a proper, cross-browser way to "empty" an IFrame? Is "about:blank" recognized without error across all browsers? Is it valid to give an IFrame an empty src?

热门标签