pstein Posted April 19, 2016 Share Posted April 19, 2016 Assume I have an element like: <div class="aaa" myattribute="foobar1111" .....>....</a> The classname "aaa" is unique. 1.) How can I replace "foobar1111" completely (!) by "dummy2222" from javascript/jQuery? 2.) How can I replace ONLY "1111" inside the attribute by "2222" AND keep the remaining (possible unknown) text inside the attribute value whatever it is? If it is more comfortable jQuery could be used. Peter Link to comment Share on other sites More sharing options...
dsonesuk Posted April 19, 2016 Share Posted April 19, 2016 Key word 'replace', look for element with specific class ( if supposed to be unique use id instead, makes it a lot easier), reference its attribute name, use replace() to make required changes. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now