简体   繁体   中英

Firefox HTML inspector: how to copy single HTML tag?

I have a website and need to transport a form to another website. I however only need certain tags not the whole form block with all it's tables and divs.

When selecting a html-tag in inspector, I can copy inner HTML, outer HTML or CSS styles but how can I just copy that very exact tag I selected without it's child nodes, just the selected line in HTML code?

I ask this because the HTML is minified and I can't just select and copy a tag in source. Same when I chose "copy outer HTML" I get the whole HTML subtree minified, means everything in one line.

How can I quickly search and copy certain tags from the three without grabbing everything in the branch?

Edit: People, thanks for all your suggestions but please note that I wrote about a MINIFIED HTML page I have here.

Just open Debugger near Inspector

Then find page file... then copy with any select range as you want

在此处输入图片说明

UPDATE if it minify click here 在此处输入图片说明

If I understood what you want try this

在此处输入图片说明

Since your question seems unsolved yet, let me come up with a creative approach I use for similar tasks from time to time:

(1) Creative solution: Page manipulation

If you don't have a javascript framework of your choice (eg jQuery) on that page, add it using a browser-extension that adds it when page has loaded.

Then you write a bit of javascript code that removes unwanted child elements of the desired parents in a loop or so. That sounds like lots of work but since you asked this question I assume you need dozens if not hundreds of elements so it might be worth taking the time to write such loop(s).

When the code you injected processed the page and removed everything you don't want, you can then copy the code like mentioned by others here.


(2) Alternative solution: Beautify the code beforhand

If the given solution(s) don't work for you, one could try to beautify the code by copying the source to a webpage that auto-indends html/js code. You could then optionally save it into a html-file and approach that one again like mentioned here before.


Sidenote

If either this idea is too much work or you need this frequently you are probably approaching this on the wrong side. When working on frontend (only) you are always limited to what you have. If you could approach from the backend you could then build from the data/information whatever you need. If you could provide a bit more information about why you need this and how much code you are talking about one could maybe come up with a more sustainable solution!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM