Home > Enterprise >  Why my javascript not work? When I change the innterHtml of an element, it didn't work
Why my javascript not work? When I change the innterHtml of an element, it didn't work

Time:10-10

Why my javascript not work? When I change the innterHtml of an element, it didn't work?

here is my code:

html

<!DOCTYPE html>
<html><head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <title>403 没有权限!</title>
    <style type="text/css" media="screen">
      body {
          user-select: none;
        background-color: #eeeeee;
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      }

      .container { margin: 50px auto 40px auto; width: 600px; text-align: center; }

      a { color: #4183c4; text-decoration: none; }
      h1 { width: 800px; position:relative; left: -100px; letter-spacing: -1px; line-height: 60px; font-size: 160px; font-weight: 100; margin: 0px 0 50px 0; text-shadow: 0 1px 0 #fff; }
      p,m { color: rgba(0, 0, 0, 0.5); margin: 20px 0; line-height: 1.6; }
      #suggestions {
        margin-top: 35px;
        color: #ccc;
      }
      #suggestions a {
        color: #666666;
        font-weight: 200;
        font-size: 14px;
        margin: 0 10px;
      }

    </style>
  </head>
  <body>

    <div class="container">
    
        <br><br><br><br><br><br><br><br><br><br><br><br><br>
      <h1><strong>403</strong></h1>
      <p><strong>Request denied</strong></p>
      <p><strong>请求被拒绝</strong></p>

      <p>
        If the file you are accessing is yours, please check your login information.
      </p>
      <m>You are now login as: </m><f id="ll"></f>

    </div>

    <script src="get.js"></script>
</body></html>

js

var datac
var user

function get(){
    user = localStorage.getItem(datac)
    if(user != null){
        document.getElementById("ll").innerHtml = user
        console.log(user)
    }
    else {
        document.getElementById('ll').innerHtml = 'Please Login.'
    }
}

function checklogin(){
    $.getJSON('https://text-edit-api-default-rtdb.asia-southeast1.firebasedatabase.app/.json', function ( data ){
    datac = data['data']['password']['localstorge']['code']
    get()
})}

checklogin()




There is no any errors in console! but if I get document.getElementById('ll').innterHtml I saw the change, but there is no changes in html!

This page is the 404 page of github page, I changed some codes.

I change innter to inner

Image

I use vscode And chrome

CodePudding user response:

It is weird you don't have errors in console. Be carfeully about the uppercase letters, the correct attribute is innerHTML instead of innerHtml

CodePudding user response:

You have a syntax problem. Put innerHtml instead of innterHtml

Ref: https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML

  • Related