remove last character in id attribute
jquery
Solution
Its easy by using the `attribute$=` CSS3 selector which means "ends with" in your jQuery selection:
$("div[id$=/]").each(function(){
this.id = this.id.substr(0,this.id.length - 1);
});
Edit: Using Adobe® Browser Lab, I tested this code in IE6, IE7, Firefox 2.0 and Firefox 3.0, Safari 3.0. I have also tested locally in Safari 4.0 and Firefox 3.5. In all browsers it worked properly, and removed the trailing `/` from the id.
Problem
I am trying to remove the last character from a div id using jQuery. Currently I have: ``` <div id="foo/"></div> ``` But I need: ``` <div id="foo"></div> ``` The character is always a `/` and is generated automatically (re:annoyingly) by the CMS I am using. Having the `/` there is messing up some JavaScript linking I am trying to do. How do I correct this issue?