javascript - how to scroll to a specific div when a radio button is clicked/changed -
i trying scroll page "#table_details" using scroll plug in. can't seem working.
when click/change radio(.modemsselect) button page scrolls location of radio button clicked instead of scrolling down page table("#table_details") located. not sure if doing right or going on.
$(".modemsselect,.servicesselect").change(function (e) { var data = $("#" + this.value).serialize(); var request = $.ajax({ url: "classes/scart.php?action=add", type: "post", data: data, datatype: "html", radiobutton: $(this).attr('class') }); request.success(function (data) { //$(".in_cart").html("");//clear last item selected console.log("extra item added cart"); refreshcart(); if (this.radiobutton == "modemsselect") { $.scrollto($('#table_details')); $("#icon_check_modem").html(""); $("#icon_check_modem").html("<img src=\"../img/check_icon.png\">"); $('.modem_buttonnext').button("enable"); } else if (this.radiobutton == "servicesselect") { $("#icon_check_installtype").html(""); $("#icon_check_installtype").html("<img src=\"../img/check_icon.png\">"); $(".install_buttonnext").button("enable"); } else { } }); });
any appreciated. thank you.
working fiddle http://jsfiddle.net/epsty/
you must replace this:
$.scrollto($('#table_details'));
with this:
$('html, body').animate({scrolltop:$('#table_details').position().top}, 'slow');
Comments
Post a Comment