开发者

jQuery got some trouble with IE 6?

I am working on a web app that requires a page to dynamically loadup a textbox and multi-select on selection inside another dropdown. For this I am trying to use jQuery.

I know it would be considered a punishable act, but I got to target IE6 as a possible browse开发者_开发技巧r.

The problem is I get an 'undefined', when I try to pickup a value using $('#id').val()

Here's some snippet:

function onFormLoad(){
  alert(typeof $);  // returns 'function'
  alert($('#eventId').val());  // returns undefined
}

I have a

<select id="eventId">...</select>

Any suggestions/pointers would be really great.

Thanks


when do you call the function onFormLoad() ? have you valid options inside your select with value attribute? Have you tried to set a selected attribute to the first option?


Difficuly to tell from what you've given. A few pointers:

  • Do you have other JS libs that might be conflicting?

  • What happens if you change '$' to 'jQuery' ?

  • What do you get from alert(jQuery.constructor ); ? I would expect to see 'function Function() {[native code]}' (see: http://jsfiddle.net/5aQjD/)

  • Is this script above the jQuery script inclusion? If so, it may fail?

  • Is your code in the $(document).ready() event? If not it may be executing before everthing is loading.


you could fall back to straight javascript:

alert(document.getElementById('eventId').value);  

no it's not jQuery but it IS bulletproof..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜