jquery-cookie

“remember” div's style on click (set a cookie) - jquery and jquery cookie plugin

做~自己de王妃 提交于 2019-12-11 18:35:58
问题 I have a group of divs with mouseenter, mouseleave and click events. var originalAttributes = $('.aaa').attr('style'); $('.aaa').mouseenter(function () { $(this).css('background', '#aaaaaa'); $(this).css('border', 'solid 1px red'); }); $('.aaa').mouseleave(function () { $(this).css('background','blue'); }); $('.aaa').click(function () { var $this = $(this); update_x1(this); $this.off('mouseenter mouseleave'); }); $('#save').click(function () { $.cookie({ expires: 30 }); }); $('#clear').click

Why can't I expire a cookie with JavaScript (not HttpOnly)

吃可爱长大的小学妹 提交于 2019-12-11 08:09:47
问题 I've got a cookie being set in a framework I'm developing within via JavaScript (the framework appears to be using https://github.com/carhartl/jquery-cookie). I'm developing within this framework but don't have access to the framework code and I want to delete a cookie via JavaScript (I do not have access to anything serverside within this framework). Inspecting the cookie via Chrome, I can tell a lot about it: "domain": "www.example.com", "expirationDate": 1667235180, "hostOnly": true,

Problem with canceling a jquery animation with a cookie

对着背影说爱祢 提交于 2019-12-11 07:34:41
问题 I'd like to make a jquery animation run only once per session with a cookie. I've sort of figured out how to do this with Klaus Hartl’s cookie plugin, but, when the page is called the second time, the elements flash. I'm under the impression that $.fx.off is supposed to make jquery jump to the end state of the animation, but, the elements flash briefly, it's like instead of just jumping to the end state, it just plays through the animation really quickly. The cookie will drop out when the

Can't return to default language with Google Translate in javascript

风格不统一 提交于 2019-12-11 05:19:44
问题 i have a code uses google-translate and jquery.cookie to translate all page to other language: $(document).ready(function () { var googTrans = $.cookie('googtrans'); if (googTrans === '/es/en') { //Paint specific flag var src = $('.lang-change img').attr('src').replace('flag_en.png', 'flag_es.gif'); $('.lang-change img').attr('src', src); $('#lang-change-en').attr('id', 'lang-change-es'); } $(".lang-change").on("click",function(){ if (googTrans == '/es/en') { //If language is english return

jstree - node selection based on current navigated url

南楼画角 提交于 2019-12-11 05:03:30
问题 Today I'm using the built-in cookies of the jsTree in order to preserve user navigations in the tree. on node click in the tree the user is redirected to the corresponding page in my site and the clicked node is selected/highlighted thanks to the jsTree cookies integration. Now, I would like to to select/highlight nodes in the tree also based on a navigation among the web site, i.e., a link in the site might also be a node in the tree, for example, a grid of rows that also appears in the tree

Cookie adding another entry instead of replacing existing value

流过昼夜 提交于 2019-12-11 04:48:26
问题 I am using the popular jquery cookie plugin to set a session cookie value via javascript like so: function ChangeLoginUser(sel) { var selectedUser = sel.options[sel.selectedIndex].value; $.cookie("LoginUser", selectedUser); location.reload(true); //refresh } This function is called after user selects from a site global drop-down box option. Change the value on page1 - the cookie is set CookieName = Value1. Go to page2 - The cookie is persisting correctly Change the drop-down value to value2 -

'JSON' and 'jQuery' still undefined in Internet Explorer 7 and 8

烂漫一生 提交于 2019-12-11 03:35:32
问题 I got these three popular scripts included between my <head> tags <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/json3/3.2.6/json3.min.js"></script> <script type="text/javascript" src="/js/jquery.cookie.js"></script> When I check for errors in IE7 and 8 I get the following: 'JSON' is undefined. (IE7) 'jQuery' is undefined. (IE7 and IE8) Object doesn't support this

How do I set a cookie to expire after 1 minute or 30 seconds in Jquery?

末鹿安然 提交于 2019-12-08 15:00:59
问题 How do i set my cookie to expire after 30 sec or 1 m ? this is my code : $.cookie('username', username, { expires: 14 }); // expires after 14 days 回答1: For 1 minute, you can use: var date = new Date(); date.setTime(date.getTime() + (60 * 1000)); $.cookie('username', username, { expires: date }); // expires after 1 minute For 30 seconds, you can use: var date = new Date(); date.setTime(date.getTime() + (30 * 1000)); $.cookie('username', username, { expires: date }); // expires after 30 second

jquery Cookie set and get expanded status of divs

拥有回忆 提交于 2019-12-08 05:25:07
问题 I have a question and issue related to this thread. I have multiple divs which are loaded dynamically through c# code. We can't count the number of panels (each category) that needed to be displayed in a webpage. It might be a single or 4 or 5 sometimes more. The previous code is working properly as expected. Now, I want to retain the collapsed or expanded state of each div on a postback or page refresh. I tried to use jquery cookie, but we can't seem to set and get the cookie status for each

save .addClass with jQuery cookie or local storage

夙愿已清 提交于 2019-12-08 03:33:08
问题 I'm trying to save the .addClass every time I save a stylesheet so that the button remembers The user can toggle the option on/off. My simple html: <div id="btn-switch" class="btn-group" data-toggle="buttons"> <button class="btn btn-default" type="radio" name="options" id="option1" data-color="{T_THEME_PATH}/normal.css" autocomplete="off">off</button> <button class="btn btn-default" type="radio" name="options" id="option2" data-color="{T_THEME_PATH}/inverse.css" autocomplete="off">on</button>