开发者

jQuery code working in Safari, but half in IE

I've got the following piece of code:

vote = $('input.vote', $($("ul#statement_forms li.statement")[current])).attr("value");
alert(vote);

Where the variable current is an integer. If i run this in Safari it works as expected (it alerts the value of vote), but not in IE, though, when i run this:

alert($('input.vote', $($("ul#statement_forms li.statement")[current])).attr("value"));

IE Also alerts the value, so i guess the problem is that it wont assign the value to the variable.

I tried using jQuery 1.5.1, 1.3.1 and 1.2.6 but no difference.

I'm hoping one of you g开发者_如何学Cuys can help me out..

Thanks!


Vote isnt a global variable, it's defined at this posted line

You're missing var before vote to actually declare the variable at this point. Safari apparently doesn't care, but IE doesn't like it.

On a side note: jQuery has .val() and .val("something") functions to retrieve and set the value of input and select elements.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜