How to select code ???

How to select code ???

Hi, I am trying to create my own gui editor on how to reposition and delete html elements on a page.

My question is can jquery select all html and javascript code associate by the id or name of the element of the html code.

Lets say I  have 150 images and want to delete image 40. I name all images element followed by the number out of 150.  That way the code will select  everything in the website that touches element40.  This includes javascript and the html tags. It can delete the tag  or edit it if needed.

I am trying to create a layout editor. I just need the theory of how you can make changes to a websites code . I know how I can save but just need to know how to edit the code.