私はここにあるこの素晴らしいjqueryプラグインを使用しています...
http://appgrinders.github.com/jquery-easy-drop-down/
唯一の問題は、IE7では機能しないことです。IE7で動作させるために、構文に小さな違いが生じる場合があることを読みました。Visual Studioで、以下に示す構文エラーが発生します。これがIE7を不幸にしている原因でしょうか?Jqueryの第一人者ではないので、誰かが私を助けてくれることを願っています...
/* Cache a combined list of all dropdown elements, so each doc click isn't a DOM search */
(function( $ ){
var $dropdowns = $([]);
// Create a document click handler that will close any open dropdowns:
$(document).click(function(e) {$dropdowns.find('.dropdown-panel:visible').hide();});
var methods = {
init : function( options ) {
// Add this set to our combined cache:
$dropdowns = $dropdowns.add(this);
// Create some defaults, extending them with any options that were provided
var settings = $.extend( {}, options);
return this.each(function() {
// dropdown plugin code here
var $this = $(this);
if (settings.width) {
$this.find('.dropdown-panel').css('min-width',settings.width);
$this.find('.dropdown-panel').css('width',settings.width);
}
if (settings.maxHeight) {
$this.find('.dropdown-panel').css('max-height',settings.maxHeight);
}
/* NOTE: 2 ways to get id:
var id = this.id;
var id = $this.attr('id');
*/
// Only proceed with click-event handler if the plugin
// has not already been initialized on this given element:
if ( $this.data('initialized') )
return;
else
$this.data('initialized', true);
$this.click(function(e) {
e.stopPropagation();
$dropdowns.not(this).find('.dropdown-panel:visible').hide()
var $target = $(e.target);
// If the click is on the dropdown button,
if ($target.is('.dropdown-button, .dropdown-icon')) {
$(this).find('.dropdown-panel').slideToggle('fast');
}
// Else, if it's in the panel, do the callback.
else {
if (settings.callback) {
callback = settings.callback;
callback($target);
}
}
});
});
},
show : function( ) {
return this.each(function() {
$(this).find('.dropdown-panel:hidden').slideDown('fast');
});
},
hide : function( ) {
return this.each(function() {
$(this).find('.dropdown-panel:visible').slideUp('fast');
});
},
toggle : function( ) {
return this.each(function() {
$(this).find('.dropdown-panel').slideToggle('fast');
});
},
};//VS 2010 gives me 'Expected identifier or string' on this line where the curly brace is
$.fn.dropdown = function( method ) {
// Method calling logic
if ( methods[method] ) {
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.dropdown' );
}
};})( jQuery );