小编Oli*_*ver的帖子

如何删除特定子节点

我有以下代码

  <script>        
      function delete(){
          var e = document.getElementById('parent');
          e.removeChild(e.children[0]);
      }
</script>
Run Code Online (Sandbox Code Playgroud)
  <div id="parent">
      <div id="child">
          <input type="text" placeholder="name"> 
          <button onclick="delete()"> delete</button>
      </div>
    
      <div id="child">
          <input type="text" placeholder="age"> 
          <button onclick="delete()"> delete</button>
      </div>
  </div>
      
Run Code Online (Sandbox Code Playgroud)

当我按下删除按钮时,第一个子节点被删除。但是,我只想删除特定的子节点。例如:如果我单击名称输入字段中的删除按钮,则仅应删除名称输入字段。

html javascript dom event-handling

5
推荐指数
2
解决办法
980
查看次数

NextAuth登录成功后如何返回页面

我想在登录成功时返回到特定页面,例如,当用户提供正确的凭据时,他们应该被重定向到特定页面(例如,dashboard.js),而不是仅仅返回到index.js

索引.js

   <main >
        
        {!session && <>
          <h1>You are not signed in</h1> <br/>
          <button onClick={signIn}>Sign in</button>
        </>}
          
        
        {session && <>
          <h1>Signed in as {session.user.name} </h1> <br/>
          <button onClick={signOut}>Sign out</button>
        </>}

      </main>
Run Code Online (Sandbox Code Playgroud)

[...nextauth].js

import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'


const options = {
  providers: [
    Providers.Credentials({
      // The name to display on the sign in form (e.g. 'Sign in with...')
      name: 'UserName',
      // The credentials property is used to generate a suitable form on the sign in page.
      credentials: …
Run Code Online (Sandbox Code Playgroud)

reactjs next.js next-auth

0
推荐指数
1
解决办法
6813
查看次数

标签 统计

dom ×1

event-handling ×1

html ×1

javascript ×1

next-auth ×1

next.js ×1

reactjs ×1