how to jump to the particular section in a tab from different tab
-
Hello , I have a situation where I need to jump to a specific location from tab 1 to tab 2's certain section. Here is the sample of my code.
@{
tab1
click me 1click me 2
tab2
test1 description
- This is a test 1.
test2 description
- This is a test 2.
test3 description
- This is a test 3.
test4 description
- This is a test 4.
test5 description
- This is a test 5.
test6 description
- This is a test 6.
test7 description
- This is a test 7.
test8 description
- This is a test 8.
test9 description
- This is a test 9.
test10 description
- This is a test 10.
test11 description
- This is a test 11.
test12 description
- This is a test 12.
test13 description
- This is a test 13.
test14 description
- This is a test 14.
}
Now how do i click "Click me 1" and go to the "tabs-2" and scroll down to "test14 description"? Please help. Thank you
Dhyanga
-
Hello , I have a situation where I need to jump to a specific location from tab 1 to tab 2's certain section. Here is the sample of my code.
@{
tab1
click me 1click me 2
tab2
test1 description
- This is a test 1.
test2 description
- This is a test 2.
test3 description
- This is a test 3.
test4 description
- This is a test 4.
test5 description
- This is a test 5.
test6 description
- This is a test 6.
test7 description
- This is a test 7.
test8 description
- This is a test 8.
test9 description
- This is a test 9.
test10 description
- This is a test 10.
test11 description
- This is a test 11.
test12 description
- This is a test 12.
test13 description
- This is a test 13.
test14 description
- This is a test 14.
}
Now how do i click "Click me 1" and go to the "tabs-2" and scroll down to "test14 description"? Please help. Thank you
Dhyanga
You'll need to add an
id
to any element that you want to be a navigation target.<p id="test14">test14 description</p>
You then specify that ID in the URL:
<a href="mypage/#test14">click me 1</a>
How you ensure that
tabs-2
will be visible when you navigate to an item within the tab depends the script / CSS you're using to create the tabs. For example, with Bootstrap, something like this should work:$(function(){
$("#tabs").tab();if (location.hash){ var target = $(":target"); if (!target.is(".tab-pane")){ target = target.closest(".tab-pane"); } if (target.is(".tab-pane")){ // When the tab has finished fading in, scroll down to the target element: $("#tabs").one("shown.bs.tab", function(){ $("html, body").animate({ scrollTop: $(":target").offset().top }, "fast"); }); var id = target.prop("id"); $("a\[data-toggle='tab'\]\[href='#" + id + "'\]").tab("show"); } }
});
NB: This question has nothing to do with C#. In future, please post in the correct forum.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer