创建带bar1,bar2函数的foo函数
var foo = {
bar1: function me() {
var index = 1;
alert(me);
},
bar2: function me() {
var index = 2;
alert(me);
}
};
foo.bar1(); // Shows the first one
foo.bar2(); // Shows the second one
创建类似于$.post()的jquery函数
$.extend({
send: function (url, args, tar) {
console.log("222");
var body = $(document.body),
form = $("<form method='post' target='" + tar + "'></form>"),
input;
form.attr({ "action": url });
$.each(args, function (key, value) {
input = $("<input type='hidden'>");
input.attr({ "name": key });
input.val(value);
form.append(input);
});
form.appendTo(document.body);
form.submit();
document.body.removeChild(form[0]);
}
});
$.send(url, args, tar);
|