Get attribute name value of <input>

后端 未结 11 777
青春惊慌失措
青春惊慌失措 2020-11-29 20:11

How to get the attribute name value of a input tag using jQuery. Please help.


11条回答
  •  孤城傲影
    2020-11-29 20:27

    Use the attr method of jQuery like this:

    alert($('input').attr('name'));
    

    Note that you can also use attr to set the attribute values by specifying second argument:

    $('input').attr('name', 'new_name')
    

提交回复
热议问题