tags:

views:

58

answers:

1

Here's my code:

<script>
 $("#btn1").click(function(){
  baseURL='http://domain.com/base1';
  $("input#Race").val("btn2");
  $("input#Race").attr("id","btn2");
 });
 $("#btn2").click(function(){
  baseURL='http://domain.com/base2';
  $("input#pet").val("btn1");
  $("input#pet").attr("id","btn1");
 });
</script>
<td><input class="inputbutton" id="btn1" type=button value="btn1"></td>

What's supposed to happen, when you click the button, it changes between btn1 and btn2 and also change the baseURL variable.

But when I click the button, nothing happens.

A: 

It’s a strange idea to change ids of elements. It would surprise me if it worked. You’d better swap the buttons themselves, instead of swapping their ids.

Ilya Birman
Thanks, changed my code and made the button's id "Switch" then made it check the value of the button and do it's stuff according to that.
Hintswen