Get attribute name value of <input>

后端 未结 11 764
青春惊慌失措
青春惊慌失措 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:26

    You need to write a selector which selects the correct first. Ideally you use the element's ID $('#element_id'), failing that the ID of it's container $('#container_id input'), or the element's class $('input.class_name').

    Your element has none of these and no context, so it's hard to tell you how to select it.

    Once you have figured out the proper selector, you'd use the attr method to access the element's attributes. To get the name, you'd use $(selector).attr('name') which would return (in your example) 'xxxxx'.

提交回复
热议问题