Replace Name Attribute with Variable - JQUERY

非 Y 不嫁゛ 提交于 2019-12-14 03:58:34

问题


I am using a select element to change the search type on a media site (i.e. search by genre, search by artist).

I have created the dropdown and can get the selected option via a variable but now I need to replace the name attribute on the input element with the variable/selected option. I have seen the below code to change the "value", is there anything like this for changing the name attribute on an input element.

$("input[name$='letter']").val("a letter");

回答1:


.attr('name', 'blah')



来源:https://stackoverflow.com/questions/1959660/replace-name-attribute-with-variable-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!