Skip to content

JS – Extract Background-Image URL


Warning: Use of undefined constant gad_content_tag_filter_replace - assumed 'gad_content_tag_filter_replace' (this will throw an Error in a future version of PHP) in /home/surfer_u/labs.andrewu.net/wp-content/plugins/web-ninja-google-analytics/webninja_ga.php on line 1813
(function ($) {
	$.fn.backgroundImageUrl = function(options) {
		if (options){
			return this.each(function(){
				$(this).css('backgroundImage','url:('+options+')');
			});
		}else {
			var pattern = /url\(|\)|"|'/g;
			return $(this).css('backgroundImage').replace(pattern,"");
		}
	};
})(jQuery);

source

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*