Thanks a lot for the solution
same can be used for an image or table?
Yes you can, and as langsor stated, this is not for security, if you are trying to restrict access to something you should go with a server side solution. This will only hide it from plain site, but just remember that it is not hard to view all of your javascript no matter where you are pulling it from. Even if you don't see the javascript in the source and are getting it from another file, it can be read with things like the "web developer" add on with firefox and other applications.