开发者

jQuery 1.4.3 selector problem in IE7

I'm trying to get an element like so:

var billingID = 'table[id^="table.form.billingaddress"] #'+ shipp开发者_如何学GoingID;
var billingName = $(billingID).attr("name");

It works as I'd expect in FF, Chrome, IE8, IE9 but IE7 gives me 'undefined'

Help will be greatly appreciated. ... and I'm stuck with the way IDs are generated in the document :-(


This code works in IE 7.0.5730.13:

<table id="table.form.billingaddress.0">
    <div id="nameFirst"></div>
</table>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script>
    $(document).ready(function() {
       // alerts with "table.form.billingaddress.0"
       alert($('table[id^="table.form.billingaddress"]')[0].id);
       // alerts with "nameFirst"
       alert($('table[id^="table.form.billingaddress"] #nameFirst')[0].id);
    });
</script>

I'm not sure why this is working at all, the periods in the table id should be escaped.

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").

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜