I want to select the first option in a control so I write:
$("#MySelect").val($("#MySelect option:first").val());
Now go ahead and copy-paste the following into the google closure compiler:
// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level ADVANCED_OPTIMIZATIONS
// @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/jquery-1.7.js
// ==/ClosureCompiler==
$("#MySelect").val($("#MySelect option:first").val());
You'll get this error:

I don't see why the compiler is complaining! What's the problem?
Thanks for your suggestions.
You could do this $("#MySelect").prop("selectedIndex", 0). It's simpler and passes closure compiler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With