我使用库(hideshare,https://github.com/arnonate/hideshare)在我的页面中插入社交分享链接。 我构建了我的对象,但是我必须在创建后修改值参数(所以我必须能够访问元素并修改它们)。
以下是该函数的代码:
;(function(window, $) {
"use strict";
// HIDESHARE PUBLIC CLASS DEFINITION
// =================================
var Hideshare = function (elem, options) {
this.elem = elem;
this.$elem = $(elem);
this.options = options;
};
Hideshare.prototype = {
defaults: {
link: document.URL,
title: document.title,
description: '',
media: null
},
init: function() {
this.config = $.extend({}, this.defaults, this.options);
this.wrapHideshare();
return this;
},
wrapHideshare: function() {
var output = output,
shareTitle = this.config.title,
shareLink = this.config.link,
shareMedia = this.config.media,
shareDescription = this.config.description;
}
};
Hideshare.defaults = Hideshare.prototype.defaults;
$.fn.hideshare = function(options) {
return this.each(function() {
new Hideshare(this, options).init();
});
};
window.Hideshare = Hideshare;
})(window, jQuery);
要创建新对象,很简单:
$(".share").hideshare({
link: "https://i.ytimg.com/vi/To39sfLShv4/mqdefault.jpg",
media: "https://i.ytimg.com/vi/h6malT0qlj4/mqdefault.jpg"
});
但是当创建对象时,如何访问和修改“媒体值”? 我必须创建一个变量吗?
var obj = $(".share").hideshare ??
感谢