I would like to ask how to return variable 'get_cookies' from function 'save_value'. Then write its value in mouseleave event.
Function 'get_cookies' will save change from input. An error is in return i think.
Sorry for my bad English.
Here is code:
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
function save_value(value) {
var get_cookie = value;
return get_cookie;
};
$('#submit_value').live('click', function() {
var get_value = $('#get_value').val();
save_value(get_value);
});
$(document).mouseleave(function() {
var create_cookie = save_value();
console.log('save: ' + create_cookie);
});
});
</script>
</head>
<body>
<input type="text" id="get_value" />
<input type="button" id="submit_value" value="Click" />
<div></div>
</body>
console log:
save: undefined
Thx for answer.