function - jquery how to access / modify a element in object -
i use library (hideshare, https://github.com/arnonate/hideshare) inserts social sharing links in page. build object, have modify value parameters after creation (so have have access elements , modify them).
here code of function:
;(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);
to create new object, simple:
$(".share").hideshare({ link: "https://i.ytimg.com/vi/to39sflshv4/mqdefault.jpg", media: "https://i.ytimg.com/vi/h6malt0qlj4/mqdefault.jpg" });
but when object create, how access , modify 'media value' example ? must create variable?
var obj = $(".share").hideshare ??
thanks
Comments
Post a Comment