I have a problem with my horizontal scroll. When I inspect in chrome I don’t see errors. Could you tell me where is the problem because I can’t find it ?
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script>
$('#right-button').click(function() {
$('#content').animate({
marginRight: marginRight -"200px"
}, "fast");
});
$('#left-button').click(function() {
$('#content').animate({
marginLeft: marginLeft +"200px"
}, "fast");
});
</script>
<style type="text/css">
#browser {
float: left;
width: 300px;
overflow: hidden;
white-space: nowrap;
}
</style>
</head>
<body>
<div id="browser">
<a href="#" id="left-button">BACK</a>
<div id="content">
This is the content of the text which should be scrolled.
</div>
<a href="#" id="right-button">NEXT</a>
</div>
</body>
You’re referring to
marginRightwhich isn’t a variable defined in your page.Replace
by
From the documentation :
There is another logical problem if I guess your intent : you can’t play like this with both left and right margin. See the Demonstration to see what can work.