Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change HTML <head> content using javascript/jquery

Tags:

html

head

let's assume that the content is empty as given below.

<head> 

</head>

If I want to change it dynamically to

<head> 
<script src="jquery-1.8.0.min.js"></script>
</head>

is there anyway that AppInventor can do that?

like image 900
user5045 Avatar asked May 25 '26 19:05

user5045


2 Answers

You can select it and add to it as normal:

$('head').append('</script>');

JavaScript:

document.getElementsByTagName('head')[0].appendChild( ... );

Make DOM element like so:

script=document.createElement('</script>');
script.src='src';

document.getElementsByTagName('head')[0].appendChild(script);
like image 74
underscore Avatar answered May 28 '26 15:05

underscore


Some simple javascript to change the innerHtml of document.head will work

document.head.innerHTML = "<script src=\"jquery-1.8.0.min.js\"></script>";
like image 29
Zero Fiber Avatar answered May 28 '26 17:05

Zero Fiber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!