admin管理员组文章数量:1323348
I have a input box like this
<input type="text" class="form-control" onblur="getProductqty('+this.value+')"
placeholder="0" id="'+productSizeId+'">
And i am trying to get the value of the input field by the getProductqty()
function.
I have tried like this
function getProductqty(productQnty)
{
console.log(productQnty);
var $this = jQuery(this);
console.log($this.value );
}
From the both i found the undefined value. Please any help. Thank you in advance.
I have a input box like this
<input type="text" class="form-control" onblur="getProductqty('+this.value+')"
placeholder="0" id="'+productSizeId+'">
And i am trying to get the value of the input field by the getProductqty()
function.
I have tried like this
function getProductqty(productQnty)
{
console.log(productQnty);
var $this = jQuery(this);
console.log($this.value );
}
From the both i found the undefined value. Please any help. Thank you in advance.
Share Improve this question edited Aug 9, 2018 at 5:57 wazz 5,0785 gold badges22 silver badges36 bronze badges asked Aug 9, 2018 at 5:54 RanjitRanjit 1,72410 gold badges30 silver badges64 bronze badges 1- 2 You're passing a hardcoded string as the argument. I have difficulty believing that it is ing out as undefined. (Possibly you are generating that HTML with embedded JS using PHP or something. You need to provide a real minimal reproducible example) – Quentin Commented Aug 9, 2018 at 5:58
2 Answers
Reset to default 4You can simply pass the reference this
to getProductqty
function and get the value of input like
function getProductqty(input){
console.log(input.value)
}
<input type="text" class="form-control" onblur = "getProductqty(this)" placeholder="0" id="productSizeId">
You can simply pass this
and get it in the function and access the value
property on it. Or if you want to pass this.value
then you dont need all those extra +
and '
function getProductqty(value){
console.log(value);
}
<input type="text" class="form-control" onblur = "getProductqty(this.value)" placeholder="0">
本文标签: javascriptGet the Value of input text on blurStack Overflow
版权声明:本文标题:javascript - Get the Value of input text on blur - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742132168a2422211.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论