How to get link href value?
import $ from "jQuery";
const page = `<!DOCTYPE html>
<html>
<head>
<link rel='up' href='123' />
</head>
<body></body>
</html>`;
const $theme = $(page);
console.log($theme.find(`link[rel='up']`).attr("href")); // undefined
I read that browser may get rid of head elements when parsed from string. Is it the case? Do i really need to use regexp?
UPDATE: In real code it's used like this inside chrome extension background script:
$.get(`link`, (theme) => {
const $theme = $(theme)
const publishedAt = $theme.find('.published').first().attr('title')
})
And it's works fine for any element inside body. I'm not sure why it's not working even for body in sandbox...