简体   繁体   English

如何在单击保存按钮时在 output 文本上显示编辑框

[英]how can i show an edit box on output text on click with save button

how can i edit on output text on click with save button.我如何在点击保存按钮时编辑 output 文本。 please if any could help....请如果有任何帮助....

 $(document).ready(function(){ $("#btn").click(function(){ let getVal = $("#inputValue").val(); let button = `<button name="button-${getVal}">Button for ${getVal}</button>` $("#output").html($("#output").html() + " " + getVal + button); }); });
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="main"> <fieldset> <legend>jQuery input value</legend> <input id="inputValue" type="text" name="text"> </fieldset> <button id="btn">display value</button> <div id="output"></div> </div>

 $(document).ready(function(){ $("#btn").click(function(){ let getVal = $("#inputValue").val(); let button = `<button onclick="Update(this);" name="button">Edit/Update </button>` //let button = `<button onclick="Update(this);" name="button-${getVal}">Edit/Update for ${getVal}</button>` $("#output").append('<tr><td><input name="test[]" type="text" value="'+getVal+'" disabled></td><td>' + button +'</td></tr>'); }); }); function Update(CurrentElement) { if($(CurrentElement).closest('tr').find('input').attr('disabled')) { $(CurrentElement).closest('tr').find('input').attr('disabled',false); } else { $(CurrentElement).closest('tr').find('input').attr('disabled',true); } }
 table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%;} td, th { border: 1px solid #dddddd; text-align: left; padding: 8px;} tr:nth-child(even) { background-color: #dddddd;}
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="main"> <fieldset> <legend>jQuery input value</legend> <input id="inputValue" type="text" name="text"> </fieldset> <button id="btn">display value</button> <table id="output"><tr><th>Value</th><th>Action</th></tr></table> </div>

May be this can help you.可能这可以帮助你。

 $(document).ready(function(){ $("#btn").click(function(){ let getVal = $("#inputValue").val(); $('#output').val(getVal); }); $("#save").click(function(){ let getValNew = $("#output").val(); $('#inputValue').val(getValNew); }); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="main"> <fieldset> <legend>jQuery input value</legend> <input id="inputValue" type="text" name="text"> </fieldset> <button id="btn">display value</button> <input type="text" name="text-out" id="output"> <button id="save">Update value</button> </div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过单击将按钮的值添加到文本框? - How can I add the value from button to the text box by click? 在我的布局中,当我单击编辑文本时,在编辑文本下方有一个编辑文本和一个按钮,然后在软输入上方显示布局 - In my layout one edit text and one button below edit text when i click on edit text then layout show above the soft input 如何通过单击按钮保存 cookie? - How can I save a cookie with the click of a button? 如何将选择为“文本”的SELECT框发送到按钮上的函数,以便使用angular进行ng-click? - How can I send a SELECT box selected “text” to a function on a button for ng-click using angular? 如何在点击时显示不同的文字? - How can I show different text on click? 文本框显示更新的文本并在按钮单击时保存 - Text box to display updated text and save on button click 如何使用按钮单击在asp.net Web应用程序中显示“另存为”对话框 - How to Make show Save As Dialog box in asp.net web Application using Button click 如何在 div 框中显示来自 javascript innerhtml 的文本输出,而不会出现文本溢出和 html/css 样式 - How can I show a text-output from javascript innerhtml in a div-box without the text overflowing and with html/css styling 如何在单击按钮时显示选择框选项? - How to show Select box Options on Button Click? 如何自动归档输入框并单击搜索按钮? - How can I automatically file an input box and click a search button?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM