Reputation: 4599
I have 30 result set and I want to add dynamic vertical scroll bar based on the mobile or browser height using jQuery i.e if the results are more.
<div class="banklist">
<h1>Pay using Netbanking</h1>
<input name="" type="text" class="textbox" id="filter" onkeyup="this.setAttribute('value', this.value);" value="">
<div class="list">
<img src="images/logo_citi.gif" class="img">Citibank Online
</div>
<div class="list">
<img src="images/logo_hdfc.gif" class="img">HDFC Bank
</div>
<div class="list">
<img src="images/logo_hdfc.gif" class="img">ICICI Bank
</div>
<div class="list">
<img src="images/logo_hdfc.gif" class="img">Andhra Bank
</div>
...............
...............
Upvotes: 0
Views: 1222
Reputation: 430
//check for height on any mobile devices the answer lies within adding the css overflow-y axis same is adding scroll on x axis "overflow-x"
jQuery(document).ready(function(){
if($('.banklist').height() > 120){
$('.banklist').css('overflow-y','scroll');
}
});
Upvotes: 3
Reputation: 1396
try to get the body height. try this
var BodyHeight = 0, body = window.document.body
if (window.innerHeight) {
BodyHeight = window.innerHeight;
}
else if (body.parentElement.clientHeight) {
BodyHeight = body.parentElement.clientHeight;
}
else if (body && body.clientHeight) {
BodyHeight = body.clientHeight;
}
Upvotes: 0