Navigating between divs using javascript - javascript

In my asp.net mvc application I have a modal popup.In modal popup i have three divs displayed like tabs.each div has buttons "Next","Back".on click of these buttons i want to navigate between these divs
sample code
<div id="Div1">
<ul>
<li><a id="btnone" href="#OneTab">one</a></li>
<li><a id="btTwo" href="#TwoTab">Two</a></li>
<li><a id="btnThree" href="#ThreeTab">Three</a></li>
</ul>
<div id="OneTab>
<input id="btnNext Type="button/>
<input id="btnBack Type="button/>
</div>
<div id="TwoTab>
</div>
<div>
Please suggest
Thanks

using foloowing line of code on "Onclick" event of button
$('#Div1').tabs("select", tabid);
Here tabid is the id of the tab on which you want to navigate
The code change done is
as below

Related

How to open a specific tab when <a> is click on another page and open specific tab on the other page

I have a button in my index page when clicking on that button I need to open a specific tab section of another page. the button is on one page and the tab is on the second page.
I have multiple tabs on the 2nd page but only writing here 1 tabs that one I need to open when is clicked from home page
Page 1 - Where I have a button
<p>View Example Worksheet</p>
Page 2 - tabs exist
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#w1">Worksheet</a>
</li>
<div id="w1" class="container tab-pane fade"><br>
<div class="container">
<div class="row">
<div class="col-12 col-sm-11">
<p class="f-15 gry2">The primary use of this worksheet is to provide a detailed checklist that will facilitate precise development of specifications with drawings, to ensure that all parties are talking about the same type and quality of building.</p>
<p>
</div>
</div>
</div>
</div>
Firstly this is not right way for tabs UI.
But if you want use
<script>
$(document).ready(function(){
$(".btn_readmore2").click(function(){
$("#w1").load("demo_test.txt");
});
});
</script>
other way find function is useful with is visible option you can check.
if($("#w1:visible")){
write you show action code here
}

simplemodal does not appear after loading dynamic data into a page

I am using simpelmodal to create dialog in jquery, but now the issue is in one of my html page i am adding
li elements dynamically , and when on a click of a button i try to fire $("attachment-modal-content").modal() dialog box doesnt appear until i again tap over a screen or move the screen. as soon as i move the screen it appears.
notable things is that if i dont load any li elements in the page , it popups normally.
here is the example page , initially attachment-modal-content is set to display:none
<div>
<a href="#" id="openDialog" />
<ul id="mylist">
</ul>
<div id="attachment-modal-content">
<h3>Attachment</h3>
<ul class="attachment">
<li id="imageBtn" class="green"><em><i class="fa fa-camera"></i></em><span>Image</span></li>
<li id="audioBtn" class="red"><em><i class="fa fa-volume-up"></i></em><span>Audio</span></li>
<li id="videoBtn" class="yellow"><em><i class="fa fa-video-camera"></i></em><span>Video</span></li>
<li id="linkBtn" class="blue"><em><i class="fa fa-link"></i></em><span>Link</span></li>
</ul>
<ul class="attachList">
</ul>
</div>
</div>
</div>
button code
$("#openDialog").on('click',function(){
$("#attachment-modal-content").modal();
});
once i load the date using $('#mylist').append('<li><li>') , dialog wont appear on a first button click , it appears
when i move the screen.

issue with jquery external linking

I am working on jquery. I have 4 tabs within the <li> tags. I have used jquery 1.9.1.js for my project. my <li> looks like the one below. I got a solution to use http://www.asual.com/jquery/address/docs/#api-reference. But the fact is that I have used and imported this external lib but it doesn't seem to work. The thing which i am trying to attain is when ever I select the specific <li> item and press f5 the page by default loads the first <li> item. But the thing which I am looking for is , it has to load the same selected <li> item and its contents when refreshed. any help would be appreciated.
Here is my HTML code:
<div class="container">
<div class="coolbar">
<div class="cool-inner">
<ul id="mybar" class="nav cool-tabs">
<li class="Coke">
Coke <span class="dashboard-bottom"></span>
</li>
<li class="Fanta">
Fanta<span class="Pricing-bottom"></span>
</li>
<li class="Pepsi">
Pepsi<span class="Promotion-bottom"></span>
</li>
<li class="Limca">
Limca<span class="Product-bottom"></span>
</li>
</ul>
</div>
</div>
</div>.
<div id="login">
<button type="button" id="submit" value="Login" class="btn">Click me for cool drinks</button>
</div>
And my jquery code for page refresh:
$(function() {
$('#submit').click(function() {
$('.container').show();
$('#login').hide();
$.cookie('shown', true);
});
if ($.cookie('shown')) {
$('#submit').click()
}
});
Thanks in advance.
when activating the tab you may want to set the tabs position/value in the cookie and when the page loads, check if tabs position/value exist in the cookie, then accordingly activate that tab or trigger click event on that tab.
may this help

Kendo Panelbar - Adding a checkbox to panels to select multiple panel header

What I want to achieve is to add checkboxes to the panel headers in a PanelBar like in the following fiddle which I have created.
Below is the html:
<ul id='panelbar'>
<li class='k-state-active'> <span class='k-link k-state-selected'>Tab 1 <input type="checkbox" class="cbSelect"/></span>
<div>Test 1</div>
</li>
<li> <span class='k-link k-state-selected'> Tab2 <input type="checkbox" class="cbSelect"/></span>
<div>Test 2</div>
</li>
</ul>
I've found that when you try to check the checkbox, that tab opens.
Is it possible to disable the onclick method for the clicked tab when clicking on the checkbox?
and if so, any ideas on how I can achieve this?
Just prevent the propagation :
$("#panelbar").on("click", "input.cbSelect", function(evt) {
evt.stopPropagation();
})
See : jsFiddle.

Jquery mobile: Need check box and collapsible content

I am developing an application using jquery mobile where I need to display a list of records with check box and collapsible button.
By clicking the check box user can select multiple records.
By clicking collapsible button he can view record detail.
I fond below code on internet but its not working:
<ul data-role=”listview”>
<li class="ui-li-1line-check2">
<span class="ui-li-text-main">1line-check2</span>
<form><input type="checkbox" name="c1line-check2"/></form>
<div data-role="button" data-inline="true" data-icon="plus" data-style="circle"> </div>
</li>
</ul>
Thanks!

Categories