Issue with changing an attribute with jquery
- by rshivers
Hello, I'm having an issue with changing the attribute for an id and can't seem to figure out what I'm doing wrong. I guess it doesn't help that I'm new to this also.
I have a function that tests to make sure that I am pulling the correct id from the row in my form that I have dynamically created. It goes something like this:
myFunction() {
var id = $(id).attr("id");
alert("This is my id " + id);
}
This works with no problem and when I click the button assigned to alert me of my id it will give give me the id of the dynamic row in my form. The issue is now when I try to change the id with this:
changeId() {
var newId = $(id).attr("id", "x");
alert("This is my new id " + newId);
}
What happens in this case is that it will alert saying "This is my new id [object Object]" instead of giving me the new id. Any suggestions? I'd really appreciate any help with this.