change input box and submit text after click

Solutions on MaxInterview for change input box and submit text after click by the best coders in the world

showing results for - "change input box and submit text after click"
Giorgio
18 Oct 2017
1<!DOCTYPE html>
2<html>
3<head>
4<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
5<script>
6$(document).ready(function(){
7  $("#change").click(function(){
8  var $name = $(this);
9  if(this.value=="percent"){
10     $("#percent_input").show();
11    	$("#flat_input").hide();
12        this.value = 'flat';
13        $name.text('Flat');
14
15    }else{
16       $("#percent_input").hide();
17    	$("#flat_input").show();
18        this.value = 'percent';
19        $name.text('Percent');  
20    } 
21  });
22  
23});
24</script>
25</head>
26<body>
27
28<button id="change" value="percent">Percent</button>
29
30<input id="percent_input" style="display:none" placeholder="Percent">
31<input id="flat_input" style="display:none" placeholder="Flat">
32
33</body>
34</html>
similar questions