Replace Name Attribute with Variable - JQUERY

2019-08-02 16:53发布

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条回答
迷人小祖宗
2楼-- · 2019-08-02 17:23

.attr('name', 'blah')

查看更多
登录 后发表回答