首页 > 解决方案 > 节点js按钮点击

问题描述

我有这个使用 node.js 运行的翡翠(哈巴狗)页面,我正在尝试将按钮的 id 传递到下一页。我尝试过 javascript,但它不起作用。
这是我的代码

script.
 var test = function() {
   console.log('button clicked!')
 
 }

.container
  table.tabSearch(border='0' )
      tr
        td
          h3 Barre de recherche :
        td
          input#Search(type='search' name='q' aria-label='Search through site content')
        td
          input#BtnSearch(type='submit' onclick="#" value='Rechercher')
     
     
  table.tableCat(border='0')
        tbody
            
          each dr,index in data         
           if index % 3 == 0
            tr
            
           td         
             .card
               img(src='https://cdn.glitch.com/49ffbc5c-e916-4b9d-bc7c-920348ff00c3%2F3381.jpg?v=1627158038684' alt='tapis rouge' style='width:100%')
               h1.title=dr.Nom
               p.price=dr.Prix + "$"
               p.description=dr.Description
               p.dimension=dr.Dimension
               p
                 a(href='detailCatalogue') 
                   button#dr.codeProduit(onclick='test()') Détail 
                 .btn
                  a(href='feedback') 
                   button Feedback

这是我的路线

router.get("/detailCatalogue", function(req, res, next) {
  
  res.render("detailCatalogue");
});

基本上我想要的是每当我点击时button#dr.codeProduit,我希望能够提取按下了哪个按钮。

标签: node.jspug

解决方案


推荐阅读