jquery - How can I make my footer stay at the bottom with a dynamically re-sizable form? -
i have form adds rows in jquery .afer() method (on push of button). footer positioned @ bottom of page when loads, if click button enough times, footer stays was, , overlaps rows. how can make recognize table getting larger, , needs move down? willing , comfortable using solutions involving css or javascript.
css
.footer { position:absolute; bottom:0px; width:100%; }
jquery
$(".gameschedule .addevent").bind('click', function () { $(".gameschedule tr:nth-child(2)").after('<tr><td><input type="text"</td><td><input type="text"</td><td><input type="text"</td><td><input type="text"<td><td><input type="text"</td></tr>'); });
html
<form name="gameform" class="gameschedule"><!--form games--> <table > <tr> <td colspan="5"> <table> <tr> <td align="left">team name</td> <td><input type="text" /></td> </tr> </table> </td> </tr> <tr> <td>date</td> <td>time</td> <td>opponent/event</td> <td>h/a</td> <td>location</td> </tr> <tr> <td><input type="text"</td> <td><input type="text"</td> <td><input type="text"</td> <td><input type="text"</td> <td><input type="text"</td> </tr> <tr> <td colspan="2"><input type="button" class="addevent" value="add event"/></td> </tr> </table> </form>
one way put footer in div id of 'footer', use jquery.
$(window).bind("load", function () { var footerheight = 0, footertop = 0, $footer = $("#footer"); var contentheight = 0, contenttop = 0, $content = $("#content"); positionfooter(); function positionfooter() { footerheight = $footer.height(); footertop = ($(window).scrolltop() + $(window).height() - footerheight) + "px"; contentheight = $content.height(); contenttop = ($(window).scrolltop() + $(window).height() - contentheight) + "px"; if (($(document.body).height() + footerheight + contentheight) < $(window).height()) { $footer.css({ position: "absolute" }).animate({ top: footertop }, 0) } else { $footer.css({ position: "static" }) } } $(window) .scroll(positionfooter) .resize(positionfooter) });
Comments
Post a Comment