如何将HTML按钮值作为参数传递给我的javascript? [英] How do I get HTML button value to pass as a parameter to my javascript?
本文介绍了如何将HTML按钮值作为参数传递给我的javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有多个按钮对应多个文本区域要清除。我需要发送函数来处理所有这些按钮并单独处理每个按钮
I have multiple buttons corresponding to multiple text areas to clear. I need to send to have a function to handle all of these buttons and handle each seperately
<html>
<head>
<script src="jquery-1.6.js"></script>
<script type="text/javascript">
function getUniqueButtonValue(value)
{
alert(value);
$("value").hide();
}
</script>
</head>
<body>
<button id=someUinqueId value=something>Clear Selection</button>
</body>
</html>
推荐答案
撇开你放置一个独特的事实值
属性中的id而不是 id
属性...这里是小提琴。
Setting aside the fact that you're placing a unique id in the value
attribute rather than the id
attribute... here's a fiddle.
$(document).ready(function(){
$("button").click(function(){
var me = $(this);
// do whatever with me
alert(me.val());
me.hide();
});
});
这篇关于如何将HTML按钮值作为参数传递给我的javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文