Recently, we are working with a small project (web application) for our client. During the development phase, our team are having fun with jQuery code. And in this post, I am going to share some basic jQuery code. I will make it available throughout my web application project. Indeed, I want a single method I can call on a jQuery selection that performs an opertation on the selection. So let's have fun.
Let's say I want to create a plugin that convert the input currency. For example, I have a textbox (input) that allows user to input amount of money (in Dollar) and then I will convert it to Riel currency with 4000 of interest rate.
 <div>  
     <label>Amount ($)</label>  
     <input type="text" id="txtAMOUNT">  
     <a href="#" id="btnCONVERT">Convert</a>  
   </div>  
   <div>  
     <label>Amount (៛)</label>  
     <input type="text" id="txtRESULT" readonly>  
   </div>  
   <script src="js/jquery.min.js"></script>  
   <script>  
     $.fn.toRiel = function() {  
       var amt = this.val();  
       return (amt * 4000);  
     };  
     $("#btnCONVERT").click(function(e){  
       var result = $("#txtAMOUNT").toRiel()  
       $("#txtRESULT").val(result);  
     });  
   </script>  

►►សូមអរគុណរាល់ការចូលរួមCommentរបស់អ្នក!

 
Top
Don't You Think this Awesome Post should be shared ??
| How to Create a Basic Plugin With JQuery | By អាយធីជនបទ |