Page controls moving after Toggle()
Hi All,
I'm just starting to learn using jQuery with ASP.net MVC.
I was exploring the
Toggle() method to
show/hide a div.
I was able to implement the toggle feature, but when i toggle the div, controls on rest of the page also move after toggle.
What if i just want to toggle the div without affecting rest of the controls on the page.
I tried using ''display: none;" and "visibility:hidden" but did'nt get expected result
It would be really helpful if you guys can jolt down some steps or redirect me to some URL which shows how to implement
such feature .
My Code is as bellow:
- <html>
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width" />
- <title>Title</title>
- @Styles.Render("~/Content/css")
- @Scripts.Render("~/bundles/modernizr")
- @Scripts.Render("~/bundles/jquery")
- @Scripts.Render("~/Scripts/jquery-ui-1.8.24.js")
- @RenderSection("scripts", required: false)
- <script>
- $(function() {
- function runEffect() {
- var selectedEffect = "blind";
- var options = {};
- $("#effect").toggle(selectedEffect, options, 100);
- }
- $("#button").click(function () {
- runEffect();
- return false;
- });
- });
- </script>
-
- </head>
- <body>
- <div class="rootHeader">
- <h1> Some Title</h1>
- <div style="align-items:flex-end;">
- <a href="#" id="button">Login</a>
- </div>
- <div>
- <div id="effect" style="display: none;">
- Login ID : <input type="text" name="txtNameS" value="txtNameS" />
- <p></p>
- Password : <input type="text" name="txtPS" value="txtPS" />
- </div>
- </div>
- </div>
- <div>
- <input type="text" name="ctrl1" value="ctrl1" />
- <input type="text" name="ctrl2" value="ctrl2" />
- <input type="text" name="ctrl3" value="ctrl3" />
- </div>
- </body>
- </html>