Can someone explain why the onclick propery doesn't show up or get injected? I need a way to click on this data.
Got a little test app here showing the issue
Look below to where I add the onclick property to the
<script src="https://www.gstatic.com/firebasejs/4.3.1/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyAgAShL4UzKAyNekPt92Y78Us684Fkhv4s",
authDomain: "sample-e2b57.firebaseapp.com",
databaseURL: "https://sample-e2b57.firebaseio.com",
projectId: "sample-e2b57",
storageBucket: "sample-e2b57.appspot.com",
messagingSenderId: "304885560213"
};
firebase.initializeApp(config);
</script>
<html>
<body>
<ul id="singleBus-ul"></ul>
</body>
</html>
<script>
const singleBus = document.getElementById('singleBus-ul');
var ref = firebase.database().ref("dinosaurs");
ref.orderByChild("height").equalTo(25).on("child_added", function (snapshot)
{
console.log(snapshot.key);
const li = document.createElement('li');
li.innerText = snapshot.child("height").val();
li.onclick = "location.href =
'http://stackoverflow.com/questions/3486110/make-a-list-item-clickable-
html-css';" // ******** THIS DOESN'T SHOW UP !! ********** //
li.id = snapshot.key;
singleBus.appendChild(li);
})
- Make A List Item Clickable
– Spinteractive Sep 21 '17 at 19:34