Change The ID of A Form Element Using Jquery

For More Videos Visit Our YouTube Channel




Here we consider how to change an element's ID using Jquery. Lets start with one example here. Suppose we have a button and a link inside form as shown below.

Change ID of Form Element Using Jquery, Change ID of Form Element Using JavaScript, Change ID of Form Element, Change ID of Element Using Jquery, Change ID of Element, Remove ID of Element Using jQuery, Replace ID of Form Element Using Jquery, Replace ID of Form Element, Replace ID of Element Using Jquery, jQuery, From element, HTML, PHP

On Button click, we needs to change the ID of the link.
In Jquery, on button click, we will find the link using its ID. Then change link's ID using jQuery attr as shown below.

$(function () {
     $('#btnChange').click(function(){
         $('#linkID').attr("id", "newId");
     })
})



That's all, by this way we can change the id of an element using jQuery attr.