---
title: "Jquery常见功能使用。项目功能"
author: "rainyear"
date: "2012-07-30T17:31:39Z"
tags: []
categories: ["非技术"]
slug: "jquery"
draft: false
lastmod: "2012-07-30T17:31:39Z"
id: 1612506
url: "https://rainyear.iteye.com/blog/1612506"
---

1》整个构架：
JS最好使用对像形式：
例如：
object.cms={
tyle="<%=accountyle%>",
isPass=true,
checkIsEmpty:${"#BankCheck"},
function1: function(tmp){
....

},
function2: function(){
var slet=false;
if(this.checkIsEmpty=="Y"){
this.isPass=true
}
...
},
外面可以直接访问

 if (typeof object == "undefined") object = {};
 function callJs(){
  object.cms;

}   
}

2>>
查找父类的第一个CLASS. $(test).parents(".groupIndexForMember").filter(":first").find(".BeneficiaryDetails").hide();
<div class="groupIndexForMember">
......
<class="BeneficiaryDetails"/>
<input id="test"/>
</div>
<div class="groupIndexForMember">
......
<class="BeneficiaryDetails"/>
<input id="test2"/>
</div>
移除下位框中的值，添加一个新的值
dropDown.children().remove();
dropDown.append("<option value='Member/Director'>Member/Director</optoin>");
3>>
Jquery 打开一个新的窗口

         if ($("divResidentConfirm").length == 0){
            var divConfirm = $('<div id="divResidentConfirm" style="display:none;padding:10px 20px 0px 20px;"></div>');
            divConfirm.append('<p>You <span style="font-weight:bold;">must</span> be an Australian resident for tax purposes to open an account.</p>');
            divConfirm.append('<p>If you are an Australian resident for tax purposes, please return to the application and tick the Yes option. </p>');
            divConfirm.append('<p>If not, your application cannot proceed and will not be saved.</p>');
            $("body").append(divConfirm);                    
        }
       
        $("#divResidentConfirm").dialog({
            resizable: false,
            autoOpen: false,
            title: "Warning",
            closeText: "hide",
            width: 600,
            height: 210,
            modal: true,
            buttons: {
                "Return to Application": function() {
                    $( this ).dialog( "close" );
                },
                "Exit Application":function() {
                    $( this ).dialog( "close" );                    
                    window.parent.location.href =  "<%=request.getContextPath()%>";
                }
            }
        });

 $("#divResidentConfirm").dialog("open");

打开一个新的窗口

5》
 $("label.selection input").click(function(e){
            var el = $(e.target);
            if(el.attr("id").indexOf("Australia") != -1){
                el.parents(".row").next().show();
                el.parents(".row").next().next().hide(); 
            }else{
                el.parents(".row").next().hide(); 
                el.parents(".row").next().next().show(); 
            }
            if (el.attr("id").indexOf("AustralianResident") != -1 && el.attr("id").indexOf("_N") != -1){
                e.preventDefault();
                e.stopPropagation();
                $("#"+el.attr("id").replace("_N", "")).val("Y");
                $("#divResidentConfirm").dialog("open");
            }
            
         });
点击触发事件。
6》
            $(".b2b_tab4_otherAccount").click( function() { self.NominatedChoices_Change();});  

            $("input:radio").click( function() { self.BrokerAccountYesNo_Change();});


3>>