Create a dummy DOM element and add the string to it. Then, you can manipulate it like any DOM element.
var el = document.createElement( 'html' ); el.innerHTML = "<html><head><title>titleTest</title></head><body><a href='test0'>test01</a><a href='test1'>test02</a><a href='test2'>test03</a></body></html>"; el.getElementsByTagName( 'a' ); // Live NodeList of your anchor elements
Edit: adding a jQuery answer to please the fans!
var el = $( '<div></div>' ); el.html("<html><head><title>titleTest</title></head><body><a href='test0'>test01</a><a href='test1'>test02</a><a href='test2'>test03</a></body></html>"); $('a', el) // All the anchor elements
Related Posts:
- jQuery document.createElement equivalent?
- How can I scroll to an element using jQuery?
- Include another HTML file in a HTML file
- How to resolve the C:\fakepath?
- JavaScript get element by name
- Uncaught TypeError: Cannot read property ‘top’ of undefined
- How can I select an element by name with jQuery?
- Retrieve the position (X,Y) of an HTML element
- Cannot read property ‘style’ of undefined — Uncaught Type Error
- Failed to load resource: the server responded with a status of 404 (Not Found)
- Maximum call stack size exceeded error
- Google Chrome Uncaught (in promise) DOMException while playing AUDIO
- How to make a word underline in Markdown
- ChartJS beginAtZero, min, max doesn’t work
- how to fix : ” TypeError: Cannot read property ‘addEventListener’ of null”…?//
- ReferenceError: $ is not defined
- React.js: Set innerHTML vs dangerouslySetInnerHTML
- jQuery.click() vs onClick
- Remove element by id
- Check if checkbox is checked with jQuery
- Add swipe left/right to web page, but use default swipe up/down
- How can I get the data-id attribute?
- Check if checkbox is checked with jQuery
- How to make JavaScript execute after page load?
- Angular: mat-form-field must contain a MatFormFieldControl
- Change Background color (css property) using Jquery
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- Get class name using jQuery
- How to clear the canvas for redrawing
- Adding options to select with javascript
- Use images like checkboxes
- How to read xml file contents in jQuery and display in html elements?
- Completely disable scrolling of webpage
- How do I scroll to an element using JavaScript?
- display variable image using cookies
- Find an element in DOM based on an attribute value
- character counter – backspace doesn’t reflect on characters remaining
- scrollIntoView Scrolls just too far
- Open URL in same window and in same tab
- How do I set/unset a cookie with jQuery?
- How to convert selected HTML to Json?
- How to Open New window on every Click
- Cannot read property ‘getContext’ of null, using canvas
- Full-screen iframe with a height of 100%
- How to move an element after another element using JS or jquery?
- Check if an element contains a class in JavaScript?
- How to use Javascript to read local text file and read line by line?
- Why is the jquery script not working?
- DOMException: Failed to load because no supported source was found
- Textarea Auto height
- Partial render in HTML/JavaScript
- How to add onload event to a div element
- Print the contents of a DIV
- How to create a HTML Cancel button that redirects to a URL
- Showing an image from an array of images – Javascript
- Embedding instagram webpage inside an iframe
- Set value to currency in
- HTML Entity Decode
- why angularjs ng-repeat not working
- Scroll to bottom of div?
- HTML5 rich-text inside textarea
- How do I check if a cookie exists?
- Highlight a word with jQuery
- Javascript: ‘window’ is not defined
- How to change the buttons text using javascript
- How do I refresh a DIV content?
- how to display a div triggered by onclick event
- jQuery sort elements using data id
- getContext is not a function
- JavaScript code to stop form submission
- How to change the text of a label?
- Change an image with onclick()
- JavaScript – Count Number of Visitor for Website
- Strip HTML from Text JavaScript
- Using “×” word in html changes to ×
- Closing Bootstrap modal onclick
- Fire oninput event with jQuery
- Changing the selected option of an HTML Select element
- window.location() not working, not opening page
- How to clear the canvas for redrawing
- Default text on input
- img onclick call to JavaScript function
- How to scroll to top of page with JavaScript/jQuery?
- How do I programmatically set the value of a select box element using JavaScript?
- Calling a JavaScript function in another js file
- How to embed an autoplaying YouTube video in an iframe?
- JavaScript code not running in HTML5 document
- Unexpected token < in first line of HTML
- How to make HTML element resizable using pure Javascript?
- How to set “style=display:none;” using jQuery’s attr method?
- WordPress Bootstrap Handburger Menu Wont Open
- How to display post content in the block editor
- Make a script work within a page
- Putting custom html/js page into Elementor as it’s own block
- Add Paypal button redirect to a specific page after completing
- Can’t Listen to KeyDown in TInyMCE Iframe (jQuery) and Pass it to Parent HTML FORM
- how to do open a link in a open window from menu bar? [closed]
- Making the HTML list to a checkbox tree with the plugin jstree [closed]
- Styling parent based on a child element of a child in a WordPress page
- I have custom html mixed with inline javascript that I want added to my WordPress site, how do I achieve this?