Javascript 提交帐户后使用jQuery隐藏按钮
当电子邮件和customer first/lastname具有值成功保存submitAccount以隐藏时,我尝试隐藏一个提交按钮 工作代码:Javascript 提交帐户后使用jQuery隐藏按钮,javascript,jquery,Javascript,Jquery,当电子邮件和customer first/lastname具有值成功保存submitAccount以隐藏时,我尝试隐藏一个提交按钮 工作代码: {literal} <script> $(document).ready(function () { $("#submitGuestAccount").click(function () {
{literal}
<script>
$(document).ready(function () {
$("#submitGuestAccount").click(function () {
if($("#email").val().trim().length>0 && $("#customer_firstname").val().trim().length>0 && $("#customer_lastname").val().trim().length>0 ) {
$('#new_account_form p.submit').hide();
}
});
});
</script>
{/literal}
<p class="submit">
<input type="submit" class="exclusive button" name="submitAccount" id="submitAccount" value="{l s='Save'}" />
</p>
再次显示要隐藏的按钮。现在,当我刷新页面按钮再次显示时?请通过添加}关闭就绪按钮
以下是更正后的代码:
<script>
$(document).ready(function () {
$("#submitAccount").click(function () {
if ($("#email").val() && $("#customer_firstname").val() && $("#customer_lastname").val()) {
$(this).hide();
}
});
</script>
<p class = "submit"> <input type = "submit" class="exclusive button" name="submitAccount" id = "submitAccount" value = "{l s='Save'}"/></p>
将条件更改为
if($("#email").val().trim().length>0 && $("#customer_firstname").val().trim().length>0 && $("#customer_lastname").val().trim().length>0 ) {
$('#submitAccount').hide();
}
希望能有帮助。我认为马蒂亚斯是对的。。您错过了就绪功能的关闭。。 有时我会使用已知的简单技巧来查看我的代码是否有缺陷。。正在添加警报方法 e、 g.添加
$(document).ready(function () {
$("#submitAccount").click(function () {
if ($("#email").val() && $("#customer_firstname").val() && $("#customer_lastname").val()) {
$('#submitAccount').hide();
alert('after the hiding method');
}
}
});
如果未调用该警报方法,则代码缺少某些内容您缺少一个};要关闭readyGreat,那就行了!但我选择了其他选择器,因为页面是签出页面,我使用的是来宾帐户。但现在我有另一个问题。这段代码工作得很好,但:当我重新加载页面或转到其他页面并返回到签出此页面时,按钮就在那个里。如何添加过滤器来检查页面何时加载?是否有pageinit函数?如果是这样,您可以在该特定页面的pageinit中将标志设置为true。并登录pagebeforeshow@user3388282I搜索pageinit函数,但我在商店文件的任何地方都找不到它。这是jquery移动应用程序吗?如果是的话,这里是。否则,您可以保留一个布尔变量最初为false,并在第一次隐藏按钮后使其为true。不,不是移动应用程序。它是prestashop,但我找不到函数pageinit,或者可能是我不知道在哪里搜索-我在几个js中搜索-签出页面使用,但没有pageinit如何添加它?
if($("#email").val().trim().length>0 && $("#customer_firstname").val().trim().length>0 && $("#customer_lastname").val().trim().length>0 ) {
$('#submitAccount').hide();
}
$(document).ready(function () {
$("#submitAccount").click(function () {
if ($("#email").val() && $("#customer_firstname").val() && $("#customer_lastname").val()) {
$('#submitAccount').hide();
alert('after the hiding method');
}
}
});