The correct writing method of JQuery function _jquery

Source: Internet
Author: User
JQuery is the correct writing format:
Introduction: <script src= "/libs/jquery/jquery.js" type= "Text/javascript" ></script>
HTML notation:
Copy Code code as follows:

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title></title>
<script src= "Modules-js/qiyi.js" ></script>
<script>
$ (function () {
Qiyiplugin.init ($ ("#zong_qiyi"));
});
</script>
<div id= "Zong_qiyi" >
Xxxxxxxxxxxxxx
</div>
jquery notation:
var qiyiplugin =
{
Init:function (parentnode) {
var self = this;
Self.parentnode = parentnode;
Refreshing local content
Self.parentnode
. On (' Refresh ', function (event) {
Self.qiyilist ();
});
},
Show
Qiyilist:function () {
var self = this;
Show internal strength Information
Self.getqiyilist (function (result) {
Console.log (result);
if (result.qiyilist) {
SELF.QIYIHTML1 ()//re-overwrite HTML to prevent repeated display of content
Self.displayqiyilist (result.qiyilist)//Show page content
}else{
Alert ("Do not get the odd art data, please check the interface");
}
});
},
Show Odd Art content
Displayqiyilist:function (qiyilist) {
var self = this;
var top = "#zong_qiyi";
$ (top). Find (' #qiyi_control_panel '). each (function () {
if ($ (this). Data (' data ')] $ (this). Remove ();
});
var line0 = $ (top). Find ("#qiyi_control_panel");
$.each (Qiyilist,function (index,item2) {
var line1 = $ (LINE0). Clone ();
$ (line1). Data (' data ', item2);//attached property data and information
$ (line1). attr (' id ', index+1);
$ (line1). Find ("#name"). HTML (item2.name);
$ (line1). Find ("#level"). HTML (item2.level);
$ (line1). Find ("#maxLevel"). HTML (item2.maxlevel);
$ (line1). Find ("#exp"). HTML (item2.exp+ "/" +item2.needexp);
$ (line1). Find ("#desc1"). HTML (ITEM2.DESC1);
$ (LINE0). before (line1);
$ (line1). Show ();
$ (line1). Find ("#upgrade")
. On (' click ', Function (event) {
var table = $ (this). Parents (' Table:first ');
var info = $ (table). Data (' data ');
Self.clicktoupgradeqiyi (info, function (result) {
if (!result.success) {
alert (RESULT.FAIL.DESC1);
}else{
alert (RESULT.SUCCESS.DESC1);
Growingplugin.playertopdata ()//Change Attrs property
Self.parentNode.trigger (' refresh ');
}
});
});
});
},
Assign HTML value-
Qiyihtml1:function () {
var string = "<table id= ' qiyi_control_panel ' class= ' table table-bordered table-hover ' style= '; width:500; ' > ";
string + = "<tr><td> Name: &LT;/TD&GT;&LT;TD id=name>haoren_ internal strength </td></tr>";
string + = "<tr><td> Current Rating: </td><td id=level></td></tr>";
String = = "<tr><td> Max rating: </td><td id=maxlevel></td></tr>";
string + + "<tr><td>exp:</td><td id=exp></td></tr>";
string + = "<tr><td> Description: </td><td id=desc1></td></tr>";
string + + <tr><td><button id= ' upgrade ' class= ' btn btn-link ' > Upgrade </button></td></tr > ";
String = = "</table>";
$ ("#zong_qiyi"). HTML (string);
},
Qi Yi Upgrade
Clicktoupgradeqiyi:function (Info,callback) {
var query = "Operation=upgradeqiyi";
Query + + "&qiyiname=" + info.name;
Toolsplugin.play (Query,callback);
},
Get a list of odd arts
Getqiyilist:function (callback) {
var query = "Operation=getqiyilist";
Toolsplugin.play (Query,callback);
},
};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.