[jQuery] Simple jQuery-Plugin Template

01/21/2014 11:31 Ravenstorm#1
Ohne Parameter:

Der Code selbst:
Code:
(function( $ ) {
	$.fn.popupContent = function() {
        //Funtions-Block
		alert($( this ).text());
	};
}( jQuery ));
Die Anwendung im Code wäre dann folgender:
Code:
$( "#textArea" ).popupContent();

Mit Parameter:

Der Code selbst:
Code:
(function( $ ) {
	$.fn.popupContent = function(additionalText) {
        //Funtions-Block
		alert(additionalText + " - " + $( this ).text());
	};
}( jQuery ));
Die Anwendung im Code wäre dann folgender:
Code:
$( "#textArea" ).popupContent("Headline");
Das ganze soll natürlich nur als Template dienen um weitere und komplexere Funktionen zu implementieren.