-2

I have this submit button.

<input id="bulkBtn" name="cat" value="delete" />

Now I want to get access to name attribute of this Jquery Object.

var bulkBtn = $('#bulkBtn');

//how can I get to bulkBtn's name attribute???

Does anyone know how to do it?

I know I can get access to name attribute of input tag like this. But, I want to know how to get to name attribute that is contained in Jquery Object.

$("input[name='foo']");

Thanks in advance!!!

4

3 に答える 3

3
var name = $("#bulkBtn").attr("name");
于 2013-09-03T09:30:09.847 に答える
3

関数の使用attr:

var bulkBtn = $('#bulkBtn');
var name = bulkBtn.attr('name');
于 2013-09-03T09:29:14.063 に答える
1

単一の要素のvar name = $('input').attr('name');ように、必要な属性を取得できます。$('input').attr('id');

于 2013-09-03T09:38:54.390 に答える