jQuery-调用基于name属性的jquery按钮单击事件 [英] JQuery - Call the jquery button click event based on name property
本文介绍了jQuery-调用基于name属性的jquery按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 HTML按钮,例如
<input type="button" id="btnSubmit" name="btnName" class="btnclass" value="Click Me" />
我要基于id
属性的含义调用 Jquery按钮单击事件,
我们使用类似的代码
I want to call JQuery button click event based on id
property means,
we use the code like,
$("#btnSubmit").click(function(){
////////
});
以及基于class
属性表示的调用按钮点击事件,
我们使用类似的代码
as well as call button click event based on class
property means,
we use the code like,
$(".btnclass").click(function(){
/////////
});
我的问题是,我想基于name
属性的含义调用按钮点击事件,该怎么做?
and My question is, I want to call the button click event based on name
property means, How to do this?
推荐答案
您可以将name属性用于该特定元素.例如,可以在名称为xyz的输入元素周围设置2px的边框,可以使用;
You can use the name property for that particular element. For example to set a border of 2px around an input element with name xyz, you can use;
$(function() {
$("input[name = 'xyz']").css("border","2px solid red");
})
这篇关于jQuery-调用基于name属性的jquery按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文