最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to call <div> on submit button click - Stack Overflow

programmeradmin5浏览0评论
  • Please refer code below i m learning jquery and i want to display tag named #child on submit button click using javascript/jquery can any one help me how to call on button click

  • And also want to call #child and #home tag on >>(next button) & <<(prev button)** on button click respectively in code >> and<< is written as &lt and &glt.? can anyone help me out ?

            <div data-role="page" id="home">
                <div data-theme="d" data-role="header">
                    <h3>
                        The Grand Bhagvati
                    </h3>
                    <a data-role="button" data-inline="true" data-direction="reverse" data-transition="slide" href="#home">
                        &lt;&lt;
                    </a>
                    <a data-role="button" data-inline="true" data-direction="reverse" data-transition="fade" href="#child">
                        &gt;&gt;
                    </a>
                </div>
                <div data-role="content">
                    <div data-role="fieldcontain">
                        <fieldset data-role="controlgroup" data-mini="true">
                            <label for="textinput1">
                                User:
                            </label>
                            <input id="textinput1" placeholder="Khushu" type="text" />
                        </fieldset>
                    </div>
                    <input data-theme="d" ="submitbtn" value="Login" type="submit"  onSubmit="redirect()"/>
                </div>
                <div data-theme="a" data-role="footer" data-position="fixed" >
                    <h3>
                        Page1
                    </h3>
    
                    </div>
            </div>
    
            <div data-role="page" id="child">
                <div data-theme="d" data-role="header">
                    <h3>
                        The Grand Bhagvati
                    </h3>
                    <a data-role="button" data-inline="true" data-direction="reverse" data-transition="slide" >
                        &lt;&lt;
                    </a>
                    <a data-role="button" data-inline="true" data-direction="reverse" data-transition="fade" >
                        &gt;&gt;
                    </a>
                </div>
                <div data-role="content">
                    <div data-role="fieldcontain">
                        <fieldset data-role="controlgroup" data-mini="true">
                            <label for="textinput1">
                                User:
                            </label>
                            <input id="textinput1" placeholder="Khushu" type="text" />
                        </fieldset>
                    </div>
                    <input data-theme="d" value="Login" type="submit"  onsubmit="redirect()"/>
                </div>
                <div data-theme="a" data-role="footer" data-position="fixed" >
                    <h3>
                        Page1
                    </h3>
    
                    </div>
            </div>
    

  • Please refer code below i m learning jquery and i want to display tag named #child on submit button click using javascript/jquery can any one help me how to call on button click

  • And also want to call #child and #home tag on >>(next button) & <<(prev button)** on button click respectively in code >> and<< is written as &lt and &glt.? can anyone help me out ?

            <div data-role="page" id="home">
                <div data-theme="d" data-role="header">
                    <h3>
                        The Grand Bhagvati
                    </h3>
                    <a data-role="button" data-inline="true" data-direction="reverse" data-transition="slide" href="#home">
                        &lt;&lt;
                    </a>
                    <a data-role="button" data-inline="true" data-direction="reverse" data-transition="fade" href="#child">
                        &gt;&gt;
                    </a>
                </div>
                <div data-role="content">
                    <div data-role="fieldcontain">
                        <fieldset data-role="controlgroup" data-mini="true">
                            <label for="textinput1">
                                User:
                            </label>
                            <input id="textinput1" placeholder="Khushu" type="text" />
                        </fieldset>
                    </div>
                    <input data-theme="d" ="submitbtn" value="Login" type="submit"  onSubmit="redirect()"/>
                </div>
                <div data-theme="a" data-role="footer" data-position="fixed" >
                    <h3>
                        Page1
                    </h3>
    
                    </div>
            </div>
    
            <div data-role="page" id="child">
                <div data-theme="d" data-role="header">
                    <h3>
                        The Grand Bhagvati
                    </h3>
                    <a data-role="button" data-inline="true" data-direction="reverse" data-transition="slide" >
                        &lt;&lt;
                    </a>
                    <a data-role="button" data-inline="true" data-direction="reverse" data-transition="fade" >
                        &gt;&gt;
                    </a>
                </div>
                <div data-role="content">
                    <div data-role="fieldcontain">
                        <fieldset data-role="controlgroup" data-mini="true">
                            <label for="textinput1">
                                User:
                            </label>
                            <input id="textinput1" placeholder="Khushu" type="text" />
                        </fieldset>
                    </div>
                    <input data-theme="d" value="Login" type="submit"  onsubmit="redirect()"/>
                </div>
                <div data-theme="a" data-role="footer" data-position="fixed" >
                    <h3>
                        Page1
                    </h3>
    
                    </div>
            </div>
    

Share edited Apr 21, 2012 at 9:01 unkown asked Apr 21, 2012 at 8:51 unkownunkown 1,1265 gold badges18 silver badges39 bronze badges 3
  • what do you mean by "call #child and #home tag"? Call it to do what? – Gwyn Howell Commented Apr 21, 2012 at 9:06
  • i just tried make my question clear and formatted it – unkown Commented Apr 21, 2012 at 9:09
  • it is <div id = child> & <div id = home> – unkown Commented Apr 21, 2012 at 9:13
Add a ment  | 

2 Answers 2

Reset to default 1

To show a tag use

$('#child').show();  // where child is the id of the element

and to hide ...

$('#child').hide();

alternatively, you can simply toggle it between hide/show as follows:

$('#child').toggle();

to attach these to an onclick event of a button ...

$(document).ready(function() {
    $('#buttonID').click(function() {
        $('#child').toggle();
    });
});

hope this helps

The below code is for javascript

var Home= document.getElementById("home");

Home.style.display="none";//To hide the div
Home.style.display="";//To display the div
发布评论

评论列表(0)

  1. 暂无评论