简体   繁体   中英

Why button onlick does nothing in Jade/pug

Why my button onclick does nothing? [enter image description here][1]

doctype html
html
  head
  block content
   script.
    function changeToTextBox(){
        alert("Testing");
    }
    title User
    welcome #{name}
  body
  button(onclick="changeToTextBox()") Edit
  form(name="searchFrm", method="post")
     input(type='text', name='email')
     input(type='submit', name='search')

Fix your indentation.

doctype html
html
  head
    block content
     script.
      function changeToTextBox(){
          alert("Testing");
      }
    title User
    
  body
    p welcome #{name}
    button(onclick="changeToTextBox()") Edit
    form(name="searchFrm", method="post")
       input(type='text', name='email')
       input(type='submit', name='search')

And use a compiler like https://pughtml.com/ to view the HTML output so you can better see what's wrong.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM