gpt4 book ai didi

javascript - 如何清除 jQueryMobile 中外部页面的文本字段值

转载 作者:行者123 更新时间:2023-11-30 13:14:28 24 4
gpt4 key购买 nike

我有两个页面 index.html 和 external.html。在 index.html 中我有两个文本字段。在这些文本字段中插入一些文本并单击一个按钮,我将转到 external.html 页面。这个 external.html 页面有一个链接到 index.html 的按钮。单击该按钮时,它会将我移动到 index.html。

现在的问题是,当我从 external.html 移动到 index.html 时,文本字段保持其先前的值。我希望它在进入 index.html 页面时清除其先前的值。如何做到这一点,请帮助我。

index.html

<section id="firstpage" data-role="page">
<header data-role="header" data-position="fixed">
<h1>First</h1>
</header>

<div data-role="content" >

<script type="text/javascript" >
$( function(){
$( '#name_field' ).val( "" );

});


$(document).ready(function () {
$('.clearme').focus(function() {
$(this).val("");
});
});

</script>


<label for="name" >Name:</label>
<input type="text" name="name" id="name_field" value="" class="clearme" placeholder="Enter Name"/>

<label for="email">Email:</label>
<input type="email" name="email" id="email_field" value="" placeholder="Enter Email Id" />

<input type="submit" id="button" value="External Page" data-theme="b" onclick="_gotopage( 'http://localhost/test/external.html' );"/>
</div>

<footer data-role="footer" data-theme="d" >

</footer>
</section>

外部.html

<section id="secondpage" data-role="page">
<header data-role="header" data-position="fixed">
<h1>External</h1>
</header>

<div data-role="content" >

<script type="text/javascript" >


</script>
<input type="submit" id="comment_enter_button" value="Index Page" data-theme="b" onclick="_gotopage( 'http://localhost/test/index.html' );"/>
</div>

<footer data-role="footer" data-theme="d" >

</footer>
</section>

脚本.js

function gotopage( gotopage )
{
$.mobile.changePage($( gotopage ), { transition: "slide"});
}



function _gotopage( page )
{
$.mobile.changePage( page);
}

最佳答案

您正在寻找这样的东西吗?:

$(document).on('pageshow', function () {
$('.clearme').val("");
});

关于javascript - 如何清除 jQueryMobile 中外部页面的文本字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12605414/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com