我有以下代码
<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)
当我按下删除按钮时,第一个子节点被删除。但是,我只想删除特定的子节点。例如:如果我单击名称输入字段中的删除按钮,则仅应删除名称输入字段。
我想在登录成功时返回到特定页面,例如,当用户提供正确的凭据时,他们应该被重定向到特定页面(例如,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)