Buon giorno.
Vorrei evitare di scrivere troppo codice, ma non so come fare.
Avevo una sola textarea e la gestivo come lo script di seguito:
codice:
$(document).ready(function() {
		$max=1500;
        $("#cOggetto").keyup(function() {
			$len=$("#cOggetto").val().length;
			$("#countBox1").text($max-$len + " caratteri");
			//controllo per non digitare altri caratteri
			if ($max-$len<0){
				$str = $("#cOggetto").val();
            	$str = $str.substring(0,$max);
                $("#cOggetto").val($str);
                $("#countBox1").text(0);
            }
        });
		
		$(function() {
			// Add markItUp! to your textarea in one line
			// $('textarea').markItUp( { Settings }, { OptionalExtraSettings } );
			$('#cOggetto').markItUp(mySettings);
			// You can add content from anywhere in your page
			// $.markItUp( { Settings } );	
			$('.add').click(function() {
				$('#cOggetto').markItUp('insert',
					{ 	openWith:'<opening tag>',
						closeWith:'<\/closing tag>',
						placeHolder:"New content"
					}
				);
				return false;
			});
			
			// And you can add/remove markItUp! whenever you want
			// $(textarea).markItUpRemove();
			$('.toggle').click(function() {
				if ($("#cOggetto.markItUpEditor").length === 1) {
					$("#cOggetto").markItUp('remove');
					$("span", this).text("get markItUp! back");
				} else {
					$('#cOggetto').markItUp(mySettings);
					$("span", this).text("remove markItUp!");
				}
				return false;
			});
		});
});
Però adesso se ne sono aggiunte altre 2(avviso_calendario e oggetto_calendario).Quindi per evitare di duplicare il codice di cui sopra, vorrei ottimizzare quello che ho, rendendolo funzionale anche per le altre due textarea.
Come si fa?
Grazie mille.