(function($){
$.nav = function(elt, options){
var base = this;
base.$elt = $(elt);
base.elt = elt;
base.$elt.data('nav, base);
base.init = function(){
base.options = $.extend({},$.nav.defaultOptions, options);
base.onClick();
// base.onHover(); // j'ai codé les deux ne sachant pas ce qui allait être décidé
};
base.close = function close(){
base.$elt.find('ul:first').children('li').removeClass(base.options.active);
};
base.openClick = function openClick(){
var that = $(this); // comment choper le this ici ?
if(that.parent('li').find('ul').length)
{
e.preventDefault(); // comment choper l'event ici ?
if($(selector).find('ul:first').children('li').children('a').not(this).parent('li').hasClass(active))
{
close(selector);
}
that.parent('li').toggleClass(active);
}
};
base.onClick = function onClick(){
$(document).on('click', function(){
base.close();
});
base.$elt.find('ul').find('ul').on('click', function(e){
e.stopPropagation();
});
base.$elt.find('ul:first').children('li').children('a').on('click', '.pop', function(e) {
e.stopPropagation();
base.openClick();
});
};
base.onHover = function onHover(){
base.$elt.find('ul:first').children('li').hover(function(){ // ici je passe par hover, pas moyen de déporter plus le code du coup ?
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.