-2
我创建了一个按钮,点击时应打开一个文本框甚至是一个对话框。一旦用户输入数据,它应该保存并在屏幕上显示数据,而不用重新加载。当我点击按钮时如何打开文本框?
我创建了一个按钮,点击时应打开一个文本框甚至是一个对话框。一旦用户输入数据,它应该保存并在屏幕上显示数据,而不用重新加载。当我点击按钮时如何打开文本框?
不知道确切的问题,但代码类似于你的要求。
<button type="button" id="btn1" >Button</button>
$('#btn1').click(function(){
$('#txtBox').show();
});
$("#txtBox").focusout(function(){
$('#output').html($("#txtBox").val());
});
$('#btn1').click(function(){
$('#txtBox').show();
});
$("#txtBox").focusout(function(){
$('#output').text($("#txtBox").val());
$('#txtBox').hide(); //Use this line if you want to hide the textbox after showing the value
});
<button type="button" id="btn1" >Button</button>
<input type="text" id="txtBox">
<div id="output"></div>
如果你想清除文本框的值每一次,那么你可以用下面的代码
$('#btn1').click(function(){
$('#txtBox').show();
});
$("#txtBox").focusout(function(){
$('#output').text($("#txtBox").val());
$('#txtBox').hide(); //Use this line if you want to hide the textbox after showing the value
$('#txtBox').val("");
});
任何代码或html分享? – artm
好吧,最新的问题,代码在哪里? – atmd
你的html看起来像什么?你使用jquery-ui吗?你试过什么了? –