Jump to content
  • 0

JQuery Cookies


salat
 Share

Question

Пол дня е*усь с этим кодом. Так ничего и не получилось. Никак не могу стили правильно приписать в скрипт.

Помогите пожалуйста. :( :(

Меню:

<ul id="menu-position" class="container">
<li class="menu">
<ul>
<li class="button"><a href="#" class="green">Одежда<span></span></a></li>
<li class="dropdown">
<ul>
<li><a href="#">Девочки</a></li>
<li><a href="#">Мальчики</a></li>
<li><a href="#">Новорожденные</a></li>
<li><a href="#">Другое</a></li>
</ul></li></ul></li>
<li class="menu">
<ul>
<li class="button"><a href="#" class="orange">Доставка<span></span></a></li>
<li class="dropdown">
<ul>
<li><a href="#">Информация</a></li>
<li><a href="#">Информация</a></li>
<li><a href="#">Информация</a></li>
</ul></li></ul></li>
<li class="menu">
<ul>
<li class="button"><a href="#" class="blue">Контакты<span></span></a></li>
<li class="dropdown">
<ul>
<li><a href="#">Написать на почту</a></li>
<li><a href="#">Оставить отзыв</a></li>
</ul></li></ul></li>
<li class="menu">
<ul>
<li class="button"><a href="#" class="red">О магазине<span></span></a></li>
<li class="dropdown">
<ul>
<li><a href="#">Миссия</a></li>
<li><a href="#">История</a></li>
</ul></li></ul></li></ul></div>

Прикрутить надо память положения по кукам

<script type="text/javascript">
$(document).ready(function() {

$('ul.container>li.menu>ul>li.button>a>li>ul>li>a').click(function() { <===================ЗДЕСЬ
$('ul.container li ul li').each(function() {
$(this).slideUp(200, cookieDel($('ul.container li.menu ul li.button').index($(this)))); <===================ЗДЕСЬ
});
});

$('ul.container li.menu ul li.button').each(function(i) { <===================ЗДЕСЬ
if ($.cookie('submenuMark-' + i)) {
$(this).show();
}else {
$(this).hide();
}


$(this).prev().click(function() {
var this_i = $('ul.container li.menu ul li.button').index($(this).next()); <===================ЗДЕСЬ

if ($(this).next().css('display') == 'none') {

$('ul.container li.menu ul li.button').each(function() { <===================ЗДЕСЬ
$(this).slideUp(200, cookieDel($('ul.container li.menu ul li.button').index($(this)))); <===================ЗДЕСЬ
});

$(this).next().slideDown(200, function () {
cookieSet(this_i);
});
}else {
$(this).next().slideUp(200, function () {
cookieDel(this_i);
});
}
return false;
});
});
});
function cookieSet(index) {
$.cookie('submenuMark-' + index, 'opened', {expires: null, path: '/'});
}
function cookieDel(index) {
$.cookie('submenuMark-' + index, null, {expires: null, path: '/'});
}
</script>

Edited by salat
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy