How to get the element position using jquery ?

                          Today I would like to post something related to jquery. The topic is “How you can get the element position using jquery?”. Recently I came across some jquery plugin customization and had to get the current element position and based on that getting value from the li. So let me show you how can you get the element position and retrieving it’s value from it.
First include the jquery framework library in your page in order to work with jquery. If you have in local you can just include it else you can directly include from online library as below-

<script src="//"></script>

Now write below code to get the element position -

<script type="text/javascript">
       /*Declare variables*/
        var el;
        var elposition;
        var current;

        el = $("#your-element-id");  /*Get your element object and store into variable*/

        elposition = el.position();

        console.log("Left position of your element - "+elposition.left); /*In order to display in firebug console or you can alert also.*/

        console.log("Top position of your  element - ";

        current = elposition.left+' , '+; /*Get the current position of your element i.e x,y*/

        console.log(el.val());/*Get your element value*/



           Hope this post will help you all to get the element position using jquery. Will bring you some interesting post in future, keep visiting for interesting post here. Hope you all like my posts and helps you. Don’t forget to give a small like and share it in social networks above.

You can also join my technical groups and stay updated, You can simply click on the follow us links below-  

What is singleton design pattern and how to use singleton in php?

                      Today I have an interesting topic related to object oriented programming concept in php for you all. Many of us may be wondering “What is exactly design patterns and how to use it in our application?” Design patterns are architecture of programming which will help developers to understand, update and extend the code easily. Shortly we can say design patterns are solution of the different problems of application. There are various design patterns available, today let me explain what is singleton design pattern exactly and how to use it in your application.

What is singleton design pattern?

                  Singleton pattern which doesn’t allow system to create more than one instance of the class. Generally creating object will allocate some memory space. So creating multiple object for each class will take unnecessary more memory space and slow down your application, which can be avoided using singleton pattern. We can say like it is an object oriented principle which will allow you to create better architectural program and can boost up performance also.

For example -

Class DB
     public function __construct()

     public function connection()

     public function query()
$db = new DB();

In above example each time you try to connect with database it will create new object of the class and creating new connection which will allocate unnecessary more memory unintentionally.

How to use singleton design pattern?

Let see how can we solve above common problem with singleton design pattern –

Class DB
     private static $instance = NULL;
     private function __construct() {………. }

     public function connection(){…………}        

     public function query() { ………….   }          

    public static function get_instance()
        if(is_null(self::$instance)) {
              self::$instance = new DB();
       return self::$instance;

In this above example get_instance() method will create single instance of the class only if property is null else it will return the existing instance of the class.
For example singleton pattern -

$dbobj = DB::get_instance();

Like this we can overcome from creating unnecessary memory space and use existing object of class if exists already. Conclusion we can say singleton pattern is allowing us to limiting to create number of object for same class, and it is really easy to use.

Hope you all understand the concept now and enjoying my posts. Please visit for my new post, soon I am going to bring up some new applications and libraries which will make your work simple.

You can also join my technical groups and stay updated, You can simply click on the follow us links below-  
Follow Us On Facebook Open Source Web Developers by Appsntech facebook group Twitter Open Source Web Developers by Appsntech twitter group Google+ Open Source Web Developers by Appsntech Google group Linkedin Open Source Web Developers by Appsntech, LinkedIn group
Copyright @2011-2015 All rights reserved. Powered By- Sanjoy Dey Productions