img src toggler

$.fn.imgToggle = function(_first, _second) { var _asIs = '_on', _toBe = '_off'; if (_second !== undefined) { _asIs = _first; _toBe = _second; } else { if (_first === undefined || _first == '_on') { _asIs = '_off'; _toBe = '_on'; } } this.each(function() { var $this = $(this); if ($this[0].tagName.toLowerCase() !== 'img') { $this = $this.find('img').eq(0); } $this.attr('src', $this.attr('src').replace(_asIs, _toBe)); }); return this; };

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.