![](/img/trans.png)
[英]How to pass a function value into a text box on click event. Function value is also an output of an array
[英]How to pass text box value as argument in jquery function on click event
我想获取单击时文本框的值作为参数
<input type="text" id="remark_mention" />
//链接请点击
<a class="remark "href="javascript:void(0);"style="text-decoration:none;color:#d90000;" id="st_mention<?php echo strip_tags($row["pid"]); ?>" onClick="mention_or_remmove_remarks('<?php echo strip_tags($row["pid"]); ?>','st_mention');"> Mention</a>
我的jQuery函数如下
function mention_or_remmove_remarks(mention_id, action){
var dataString = "mention_id=" + mention_id + "&action=mention_or_remmove_remarks";//ajax code here for post mention_update.php
}
如何在链接Onclick事件中获取文本框的值
你可以得到它。
使用表格并获取:
<form>
<input type="text" id="remark_mention" name="remark_mention_ID"/>
<input type="button" onclick="foo(this.form.remark_mention_ID.value)"/>
</form>
要么 :
<input type="text" id="remark_mention" />
并在您的js文件中:
var value = $('#remark_mention').val(); // value variable has your latest value
HTML
<input type="text" id="remark_mention" />
<a class="remark "href="javascript:void(0);"> Mention</a>
JS
$('.remark').on('click', function(){
var text_val = $('#remark_mention').val();
console.log(text_val);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.