"custom jquery plugin (for understanding extends)(check it in your local)"
Bootstrap 4.1.1 Snippet by mdburhani52

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="list1"></div> <!--call jquery.js in script tag--> <!--call plugin file in script tag--> <script> $('.list1').customPlugin1({ bgColor: '#a7a7a7', data: [ {name: "mohammad", age: 24, gender: 'male', className: "myClass"}, {name: "atif",age: 24,gender: 'male'}, {name: "girish",age: 24,gender: 'male'}, ] }) </script>
(function ($) { $.fn.extend({ customPlugin1:function(params){ myFn1(this.selector, params); return }, }); var myFn1 = function(selectorName, params){ var output = ''; for (var i = 0; i < params.data.length; i++) { var customClass = ""; if(params.data[i].hasOwnProperty('className')){ customClass = params.data[i].className; } output += '<div class="' + customClass + '">' + params.data[i].name + '</div>'; } $(selectorName).html(output); $(selectorName).css({background:params.bgColor}) } })(jQuery);

Related: See More


Questions / Comments: