i have an html with 3 dropdown menu, which are
<select id="day"> <select id="month"> <select id="year">
but everytime i choose one of the value in them, after the option is selcted,then the page will keep back to the top
i have tried following the similar case in
How do I stop a web page from scrolling to the top when a link is clicked that triggers JavaScript?
i add a script in my html which is
<script>
$("#day").click(function(e) {
return false;
e.preventDefault();
});
</script>
here is my short html file
<header class="headerNavi">
<div class="headerNaviLeft">
<a href="#home">Back</a>
</div>
<div class="headerNaviRight">
<a href="#home">Cancel</a>
</div>
</header><!-- End Header -->
<!-- content -->
<section id="formDiv">
<h3>Create Link</h3>
<p class="tl01">Snap a photo or upload your own, then fill up the details
to continue...</p>
<div class="rowBox">
<span class="photoBox">
<img id="imageFile" name="imageFile" src="" style="width:100%; min-height:150px;" onclick="getPhoto(navigator.camera.PictureSourceType.PHOTOLIBRARY);" />
</span>
</div>
<div class="rowBox">
<select id="day">
<option disabled="disabled" selected="selected" value="">
DD
</option>
<option value="1">
1
</option>
// up to 31
</select>
</div>
</section>
here is my view
define(['jquery', 'underscore', 'backbone', 'text!modules/link/linkCreateViewTemplate.html'], function($, _, Backbone, linkCreateViewTemplate) {
var LinkCreateView = Backbone.View.extend({
template: _.template(linkCreateViewTemplate),
initialize: function() {
},
events: {
"click #createButton": "create",
},
create: function(event) {
window.location.replace("#linkconfirm");
},
render: function() {
this.$el.append(this.template());
},
remove: function() {
Backbone.View.prototype.remove.call(this);
$(window).off('scroll');
}
});
return LinkCreateView;
});