I wanted to use javascript to pull in html code. I have set up the html code like so;
<html>
<div id="tesingCode">
<h1>Title</h1>
<p>testOfCodetestOfCodetestOfCodetestOfCode</p>
</div>
</html>
then I created a variable like so;
var testingTheCode = document.getElementById ("tesingCode");
and tried to add the variable to the Polymer project like so;
Polymer({
is: 'animated-grid',
behaviors: [
Polymer.NeonSharedElementAnimatableBehavior
],
properties: {
config: {
type: Array,
value: function() {
return [
{value: 1, color: 'blue'},
{value: 2, color: 'red'},
{value: 3, color: 'blue'},
{testingTheCode, color: 'green'},
{value: 5, color: 'yellow'},
{value: 6, color: 'blue'},
{value: 7, color: 'red'},
{value: 8, color: 'green'},
{value: 9, color: 'yellow'},
{value: 10, color: 'red'}
]
}
},
The full file is animated-grid.html which is available here...
https://github.com/alistairkb/Coachella/blob/master/animated-grid.html
My overall aim is to add content to the boxes before they have been pressed.
You are pretty close, I think you are looking for the innerHTML property
Check out this JSfiddle
You just need to put .innerHTML at the end of your testingcode variable
var testingTheCode = document.getElementById ("tesingCode").innerHTML;
If this isn't what you are looking for, please post a jsFiddle of your code.
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.