簡體   English   中英

第二個 JQuery 代碼不起作用

[英]2nd JQuery Code not working

我有兩個代碼,如果添加第一個,第二個不起作用,我不確定問題出在哪里以及如何解決,以下是頁面頁腳中使用的代碼:

代碼 1:

<script type="text/javascript">
$(document).ready(function () {
    var names = ["input.name","input.first_name","input.last_name","input.email","input.address","input.city","input.state","input.zip","input.phone","input.country"];
    $.each(names,function (index, item) {
        var regex = new RegExp("\\{\\{"+item+"\\}\\}","g");
        var currVal = localStorage.getItem("garlic:"+document.location.host+"*>"+item);
        $("body:contains('{{"+item+"}}')").each(function() {
            var replace_text = (currVal != null) ? currVal : "";
            var replaced = $(this).html().replace(regex, replace_text);
            $(this).html(replaced);
        });
    });
});
</script>

代碼 2:

<script type="text/javascript">

$(document).ready(function(){
    $('#agreeCheckbox').click(function(){
        $('#tmp_button-70655').toggle();
        $('#disablebtn').toggle();

});


$('#agreeCheckboxtwo').click(function(){
        $('#button-99411-155-131-111').toggle();
        $('#disablebtntwo').toggle();

});
  });
</script>

您是否嘗試刪除“就緒”之一?

<script type="text/javascript">
$(document).ready(function () 
{
    var names = ["input.name","input.first_name","input.last_name","input.email","input.address","input.city","input.state","input.zip","input.phone","input.country"];
    $.each(names, function (index, item) 
    {
        var regex = new RegExp("\\{\\{"+item+"\\}\\}","g");
        var currVal = localStorage.getItem("garlic:"+document.location.host+"*>"+item);
        $("body:contains('{{"+item+"}}')").each(function() 
        {
            var replace_text = (currVal != null) ? currVal : "";
            var replaced = $(this).html().replace(regex, replace_text);
            $(this).html(replaced);
        });
    });

    $('#agreeCheckbox').click(function()
    {
        $('#tmp_button-70655').toggle();
        $('#disablebtn').toggle();

    });

    $('#agreeCheckboxtwo').click(function()
    {
            $('#button-99411-155-131-111').toggle();
            $('#disablebtntwo').toggle();
    });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM