Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get <head> content of the current page with jquery or JS

how to get <head> content of the current page

like image 477
faressoft Avatar asked Aug 28 '10 21:08

faressoft


People also ask

What is $() in jQuery?

$() = window. jQuery() $()/jQuery() is a selector function that selects DOM elements. Most of the time you will need to start with $() function. It is advisable to use jQuery after DOM is loaded fully.

How can I get URL in jQuery?

The current URL in jQuery can be obtained by using the 'href' property of the Location object which contains information about the current URL. The 'href' property returns a string with the full URL of the current page.

How do I get the HTML inside a div using jQuery?

First, use the html() function instead of the text() function. Second, point your selector to the right node, something like . portlet-content . content_regular table .

What is $() in JavaScript?

The $() function The dollar function, $(), can be used as shorthand for the getElementById function. To refer to an element in the Document Object Model (DOM) of an HTML page, the usual function identifying an element is: document. getElementById("id_of_element").


1 Answers

You could use the javascript DOM API like this:

var headContent = document.getElementsByTagName('head')[0].innerHTML; 
like image 170
user113716 Avatar answered Oct 02 '22 19:10

user113716