Ad

Variable Value From Other JQuery Extend

- 1 answer

I have the next code

$.fn.funcion01=function(){
    var section = $('#thissection').val();
}

I need send the variable value to the other function extend

$.fn.funcion02=function(){
    var section = ??
}
Ad

Answer

Try the below snippet which keeps your value inside jquery object itself.

(function($) {
	$.fn.funcion01 = function(){
    	$.myConfigName = 'hello';
	}

	$.fn.funcion02 = function(){
	    $.fn.funcion01();
	    alert($.myConfigName);
	}
}(jQuery));

$(document).ready(function () {
   $.fn.funcion02();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Ad
source: stackoverflow.com
Ad