ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

Combining buttons #228

Closed MaxKaye closed 8 years ago

MaxKaye commented 8 years ago

I need help to combine my "translate" and "refresh" buttons into one so it looks more succinct to the user. Buttons I am trying to combine:

<span id ="test0">Chinese Character</span>: <input type="text" id="myText" value="你好">
  <br><p>Click the button to translate into English.</p>
  <button onclick="myFunction()">Translate</button><br><br>
  <button onclick="myFunctiona()">Refresh</button><br><br>

code that I have to combine:

<script>
function() {
  ("Translate").parent().hide();
  ("Refresh").click(function(){
     myFunction();
     myFunctiona();
     return false;
  });
});
</script>

And here is how it looks on site:

screen shot 2016-02-23 at 3 43 34 pm
RobertAKARobin commented 8 years ago

Just to check: you want the buttons to be smushed together, or you want to display just one button at a time?

MaxKaye commented 8 years ago

either or(would like to learn both ways)

RobertAKARobin commented 8 years ago

To smush them together, it's just CSS. There are a LOT of ways to do that.

If you want to display just one at a time, you can use Javascript to hide one and show the other:

document.getElementById("buttonOne").display = "none";
document.getElementById("buttonTwo").display = "block";
MaxKaye commented 8 years ago

That makes a lot of sense but couldn't get it to work.. I will keep tinkering.

RobertAKARobin commented 8 years ago

Use debugger to "pause" at different points in your code! Sometimes it actually IS working -- Javascript changes the style, but another line of code changes it back too quickly for you to see.