That's what I did (but I had $(this) instead) when I tried that method. But it didn't work as I had to have my mouse over the ID before I could let go of it otherwise the unbind event would not happen.
Let me show you what I mean:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Scrolls</title>
<script src="../jquery.js" type="text/javascript"></script>
<style type="text/css">
<!--
.box {
float: left;
width: 200px;
margin: 0;
padding: 2px;
border: 1px solid #000000;
}
.input {
width: 100px;
height: 25px;
margin: 0 auto;
padding: 0;
}
.bar {
position: relative;
width: 150px;
height: 25px;
margin: 0;
padding: 0;
border: 1px solid #000000;
}
.scrollBar {
position: absolute;
width: 15px;
height: 15px;
margin: 5px 0 0 -15px;
left: 49%;
padding: 0;
background: #000000;
cursor: pointer;
}
.clearFix {
clear: both;
}
-->
</style>
<script type="text/javascript">
$(document).ready(function() {
$('#scrollBar').mousedown(function(e) {
//drag(e);
draggable.init(e);
}).mouseup(function() {
$('#scrollBar').unbind('mousemove');
//$(this).unbind('mousemove', drag);
//$(this).unbind('mousemove', draggable.init);
});
});
function drag(e) {
var min = -100;
var max = 100;
var initial = $('#value').val();
$('#scrollBar').mousemove(function(e) {
$(this).css({'left' : e.pageX});
});
}
var draggable = {
init: function(e) {
var min = -100;
var max = 100;
var initial = $('#value').val();
$('#scrollBar').mousemove(function(e) {
$(this).css({'left' : e.pageX});
});
}
};
</script>
</head>
<body>
<div class="box">
<input type="text" disabled="" value="0" class="input" id="value" />
<div class="bar"><div class="scrollBar" id="scrollBar"></div></div>
</div>
</body>
</html>
Bookmarks