I am trying to scroll div using button. I am using this solution to resolve my problem. However I am getting error Uncaught TypeError: view.css is not a function. I added jquery plugins but still got this error.
Here is my code
<div class="bstimeslider">
<div id="rightArrow"></div>
<div id="viewContainer">
<div id="tslshow">
<?php foreach($activity_data as $list):?>
<div class="bktibx">
<div>
<?php
if (isset( $list['coverimage']) && $list['coverimage']!=""){
echo '<img src="'.$list["coverimage"].'" height="90" width="80" >';
}else {
echo '<img src="'.WEBSITE_URL.'views/site/activity_placeholder.png" height="90" width="80" >';
} ?>
</div>
<div>
<h4><a style="font-size: 20px;font-weight: bold;color:#48a4ca" href="<?php echo WEBSITE_URL ;?>site/eventDetail/<?php echo $list['_id']; ?>"><?php echo $list['title']; ?> </a></h4>
<?php
$ro= strlen($list['description']);
if($ro >100){
$small = substr($list['description'], 0, 100);
echo $small."...";
} else {
echo strip_tags($list['description']);
}
?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<div id="leftArrow"></div>
</div>
and jquery
<script type="text/javascript">
var view = $("#tslshow").attr('id');
var move = "100px";
var sliderLimit = -750
$("#rightArrow").click(function(){
var currentPosition = parseInt(view.css("left"));
if (currentPosition >= sliderLimit)
view.stop(false,true).animate({left:"-="+move},{ duration: 400})
});
$("#leftArrow").click(function(){
var currentPosition = parseInt(view.css("left"));
if (currentPosition < 0)
view.stop(false,true).animate({left:"+="+move},{ duration: 400});
});
</script>
When i click on button I got error saying Uncaught TypeError: view.css is not a function.
viewis not a jquery object. Wrap it in$(view)to access jquery lib methods.var view = $("#tslshow").attr('id');enough to usevar view = $("#tslshow");$ is not defined