You do not want to change ownership of /opt or even /opt/lampp. These directories are owned by root for a reason: security . If you go down the path of changing ownership of directories away from root, you are making your system less safe and may open yourself up to serious problems.
The best way to do what you're trying to do is to use a solution similar to what someone here already suggested: use the gksudo command. However, because it's tedious to constantly open a terminal to type the full command, create a shell (.sh) file instead.
1) Open a text editor (something like gedit, leafpad, kate, etc.) and type in the following:
gksudo nautilus /opt/lampp/htdocs
2) Save the file on your Desktop as htdocs_open.sh
3) Open the terminal and type the following (this will change directories to the Desktop, where the above file, htdocs_open.sh, is saved.):
4) The type in the following (this will make your .sh file executable):
chmod +x htdocs_open.sh
5) Close your terminal and then look for your file, htdocs_open.sh, on your desktop. Double click on it. A window will pop-up asking for your password. When you type it in the xampp htdocs folder will open along with root privileges.
Additional note! Since you are using Xampp on Linux, it might be convienient for you to also repeat the above steps using these codes:
To start Xampp:
gksudo /opt/lampp lampp start
To stop Xampp:
gksudo /opt/lampp lampp stop
To open a text editor (gedit is used here) as root. This will allow you to save to the htdocs folder because opening gedit as root means you can save into the htdocs folder as root.
Remember! You will need to make the .sh file executable by running the chmod +x command.