如何在JavaScript中仅隐藏文本值(How to hide only text value in JavaScript)

编程入门 行业动态 更新时间:2024-10-28 10:31:03
如何在JavaScript中仅隐藏文本值(How to hide only text value in JavaScript)

我在JavaScript和Html代码中有一些代码这很好(?)但问题是文本框也消失了。 有人可以帮忙吗?

function getProductBarcode() {
    var barcode = $('#productBarcode').val();
    document.getElementById('#pos-RightTitle').style.display = 'block';
   
    $.post('functions/pos-calculation-process.php', {barcode:barcode})
        .done(function(data){
            $('#pos-RightTitle').html(data);
            setTimeout(function(){
                $('#productBarcode').hide();
            }, 300)
        });
    
    return false;
} 
  
<div class="input-group">
    <span class="input-group-addon">
        <span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span>
    </span>
    <input type="text" class="form-control" id="productBarcode"onchange = "getProductBarcode()" placeholder="Scan Barcode" aria-describedby="basic-addon1">  
</div> 
  
 

I have some code in JavaScript and Html codes This works fine(?) but the problem is textbox also disappeared. Can anyone help?

function getProductBarcode() {
    var barcode = $('#productBarcode').val();
    document.getElementById('#pos-RightTitle').style.display = 'block';
   
    $.post('functions/pos-calculation-process.php', {barcode:barcode})
        .done(function(data){
            $('#pos-RightTitle').html(data);
            setTimeout(function(){
                $('#productBarcode').hide();
            }, 300)
        });
    
    return false;
} 
  
<div class="input-group">
    <span class="input-group-addon">
        <span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span>
    </span>
    <input type="text" class="form-control" id="productBarcode"onchange = "getProductBarcode()" placeholder="Scan Barcode" aria-describedby="basic-addon1">  
</div> 
  
 

最满意答案

如果您只想清除文本表单输入,请在setTimeout函数中替换此代码:

$('#productBarcode').hide();

有:

$('#productBarcode').val('');

If you only want to clear the text form input replace this code in setTimeout function:

$('#productBarcode').hide();

with:

$('#productBarcode').val('');

更多推荐

function,class,getProductBarcode,电脑培训,计算机培训,IT培训"/> <meta name=&q

本文发布于:2023-07-27 22:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1296663.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   如何在   text   JavaScript   hide

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!