zoukankan      html  css  js  c++  java
  • jquery 相关操作笔记

    设置当前值选中:

    1:遍历

        str = xxx;
        $("#xxx option").each(function(){if($(this).text() == str){
            $(this).attr("selected",true);
            }
        });  

    同理根据val
        str = xxx;
        $("#xxx option").each(function(){if($(this).val() == str){
            $(this).attr("selected",true);
            }
        });  
    
    

    2:利用选择器:

     $("#xxx option[value='xxx']").find("option[value='xxx']").attr("selected",true);//option[value='xxx'] 不支持text

    3:获取值:

      $('#xxx option:selected').html();或者val

    3:value绑定的是json 判断 json相等代码:

    /*
    *json比较相等
    */
    function compareObject(jsonObj1, jsonObj2) {
        if (typeof jsonObj1 != typeof jsonObj2) return false;
        if (typeof jsonObj1 == 'object') {
            for (var o in jsonObj1) {
                if (typeof jsonObj2[o] == 'undefined') return false;
                if (!compareObject(jsonObj1[o], jsonObj2[o])) return false;
            }
            return true;
        } else {
            return jsonObj1 === jsonObj2;
        }
    }

     选择器:

    子页面(iframe查找父页面id)

     $(window.parent.document.getElementById("iframeShowBadPoint"))

    父页面调用子页面方法(iframe)

    ifmMap.window.fnSeMapType($(this).val());

    ifmMap是子页面的iframe的name , fnSeMapType("xx")是子页面的方法。

    jquery 解析xml IE失败解决。

    success: function (result) {
                       var res;
                           if($.browser.msie){
                                 res = new ActiveXObject("Microsoft.XMLDOM");
                                 res.async = false;
                                 res.loadXML(result.d);
                             }else{
                                 res = result.d; 
                             }
    var xmlConten=$(res).find("marker");
    if(xmlConten.length>0){xmlConten.each(function(){
    })
    }else{
    //no data;
    }
    }
  • 相关阅读:
    c++中的 三/五原则
    3. 无重复字符的最长子串
    c++中的单例模式
    bfs 以及 dfs 常用解题思路
    经济学的三个问题
    gtihub 上一些值得学习的项目
    994. 腐烂的橘子
    96. 不同的二叉搜索树
    some idea
    Libco协程库
  • 原文地址:https://www.cnblogs.com/y112102/p/2854653.html
Copyright © 2011-2022 走看看