Home > front end >  How can click on the button to change the value of the value
How can click on the button to change the value of the value

Time:10-30

& lt; The input value="0" & gt; & lt; Button> & lt;/button>
Click on the button how to make the inside of the input value the value of the change

CodePudding user response:

JQuery
& lt; Input the id="inp" value="0" & gt; & lt; The button id="BTN" & gt; & lt;/button>
$(" # "BTN). Click (function () {
$(" # inp "). Val (" value ");
});

CodePudding user response:

& lt; Input the id="inp" value="0" & gt; & lt; Button onclick="f ()" & gt; & lt;/button>
JavaScript
The function f () {
Document. The getElementById (" inp "). The value="https://bbs.csdn.net/topics/value";
}

CodePudding user response:

Java rookie 20 references 2 floor response:
& lt; Input the id="inp" value="0" & gt; & lt; Button onclick="f ()" & gt; & lt;/button>
JavaScript
The function f () {
Document. The getElementById (" inp "). The value="https://bbs.csdn.net/topics/value";
}

I want to click becomes the point once again changed again

CodePudding user response:

 
& lt; The input value="https://bbs.csdn.net/topics/0"/& gt; & lt; Button onclick="fn ()" & gt; & lt;/button>
The function fn () {
Var inp=document. GetElementsByClassName (" changeInput ") [0];
Inp. Value=https://bbs.csdn.net/topics/inp.value+1
}

How do you want to change to get the value to add and subtract what will do
  • Related