私はドロップダウンリストを持っています。そのオプションはページのさまざまなセクションです。ユーザーはオプションを選択し、指定されたセクションに移動します。ユーザーがページをスクロールすると、ドロップダウンをページのセクションに相当する値に変更します。私は、次のと私はページ上でスクロールすると、ページがセクションにジャンプし続け、私はドロップダウンをクリックしたときに私がドロップダウンリストから任意の値を選択することができません試してみましたjQueryを使用してナビゲーションのドロップダウンリストの値を変更します
<select name="ddlNavigation" id="ddlNavigation" class="form-control myDropdown" onchange="document.location = this.value;" style="width:100%;">
<option value="#Introduction">Introduction</option>
<option value="#EntryRequirements">Entry Requirements</option>
<option value="#CourseStructure">Course Structure</option>
<option value="#Application">Application</option>
</select>
...
<div id="Introduction" class="contentPanel" Name="Introduction">
.. some content here
</div>
<div id="EntryRequirements" class="contentPanel" Name="Introduction">
.. some content here
</div>
<div id="CourseStructure" class="contentPanel" Name="Introduction">
.. some content here
</div>
<div id="Application" class="contentPanel" Name="Introduction">
.. some content here
</div>
:これはドロップダウンです。
var introduction = $('#Introduction');
var entryRequirements = $('#EntryRequirements');
var courseStructure = $('#CourseStructure');
var application = $('#Application');
$(window).bind('mousewheel scroll DOMMouseScroll MozMousePixelScroll scrollstop', function (e) {
if (introduction.length > 0 && $(window).scrollTop() < (introduction.height() + introduction.offset().top)) {
$('#ddlNavigation').val('#Introduction').change();
} else if ((entryRequirements.length > 0) && $(window).scrollTop() > (introduction.offset().top + introduction.height()) && $(window).scrollTop() < (entryRequirements.offset().top + entryRequirements.height())) {
$('#ddlNavigation').val('#EntryRequirements').change();
} else if ((courseStructure.length > 0) && $(window).scrollTop() > (entryRequirements.offset().top + entryRequirements.height()) && $(window).scrollTop() < (courseStructure.offset().top + courseStructure.height())) {
$('#ddlNavigation').val('#CourseStructure').change();
} else {
$('#ddlNavigation').val('#Application').change();
}
});
あなたのコード例には、EG:entryRequirementsとcourseStructureという値がわからないという情報がたくさんあります。サンプルコードを最小限に減らすことができれば、より良い回答が得られます – TolMera