What is a good way to switch a number at the end of a string?
Im trying to change the value 0 to value 1 at the end of a URL when a button is clicked. (And vise-versa)
So if I have this:
- <a class="important_ajax" href="projects/important_ajax/0"></a>
Them the part here should be simple but im unsure of a good way to do this easily:
- $(".important_ajax").click(function() {
- $obj = $(this); // So I can use THIS object inside of other objects.
- $url = $obj.attr('href'); // This is the URL: projects/important_ajax/0
- // How can i make that link's last digit in the HREF turn to a 1 here?
- // So it turns into this:
- // projects/important_ajax/1
-
- return false;
- });