ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

为什么我的Javascript功能只能运行几次?

2019-12-09 04:36:48  阅读:281  来源: 互联网

标签:jquery-selectors jquery-plugins javascript gwt jquery


我的沙箱在这里:http://9.latest.truxmap.appspot.com/

首先点击地图上的标记(如果在页面加载时没有标记,请选中导航小部件中的“即将开放的食品卡车”框).接下来转到“评论”标签.

在GWT中,每次打开标记时,我都会调用javascript函数resizeReviewTab()来纠正由于状态和查看标签中的内容是动态的而引起的样式问题.如果使用Javascript,则您会在“评论”标签的文本区域上方看到STARS而不是单选按钮.否则,您将看到普通的单选按钮.

我无法弄清楚标记DOESNT正确打开时会发生什么.它如何才能工作一次,然后又不能再工作,然后在几个不同的标记之后又能工作?这就是所谓的函数:

function resizeReviewTab(){ 

    $('#content').text(""); 

    $('.statusWindowB').css('height', $('.statusWindowA').css('height'));                   

    $('.name-sliding').focus(function() {

        $('.name-label-sliding').animate({ marginLeft: "133px" }, "fast");

            if($(this).val() == "name")
                $(this).val() == "";

        }).blur(function() {

            if($(this).val() == "") {
                $(this).val() == "name";
                $('.name-label-sliding').animate({ marginLeft: "12px" }, "fast");
            }
        });     

    $('.content-sliding').focus(function() {
            $('.content-label-sliding').fadeOut("slow");
    });

    starify();  
} 

starify()是jQuery插件jquery.stars的javascript,进行了一些修改,可见此处:http://9.latest.truxmap.appspot.com/lib/jquery.rating.js

我需要调用此函数,因为如果仅将其加载到html文档的开头,则通过单击地图创建的信息窗口都不会将其单选按钮更改为星形.

这很麻烦,我期待您的答复.谢谢!

解决方法:

这些位肯定坏了

if($(this).val() == "name")
    // next line is checking whether val equals ""
    // we already know it equals "name"
    // so it returns false(which is discarded)
    $(this).val() == ""; "name" ,

if($(this).val() == "") {
    // next line is checking whether val equals "name"
    // we already know it equals ""
    // so it returns false(which is discarded)
    $(this).val() == "name";
    $('.name-label-sliding').animate({ marginLeft: "12px" }, "fast");
}

我想你是说

if($(this).val() == "name")
    $(this).val(''); // sets val to nothing

if($(this).val() == "") {
    $(this).val("name"); // sets val to "name"
    $('.name-label-sliding').animate({ marginLeft: "12px" }, "fast");
}

标签:jquery-selectors,jquery-plugins,javascript,gwt,jquery
来源: https://codeday.me/bug/20191209/2096615.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有