1

EDIT: I'm a fool. I didn't have jQuery loaded on my jsFiddle. I thought it automatically came loaded with a new Fiddle. Please disregard.

Alright, I've been trying to get this to work and can't for the life of me figure it out. I'm sure it's something insanely easy and I'm just not seeing it.

I have a span with pre-populated text inside of it. I want to click the button and change the text inside of the span to something else. Then I want to click the other button and change the text again.

Any thoughts? Thanks!

HTML

<div>
    <button id="bye">Bye</button>
    <button id="hello">Hello</button>
</div>
<div>
    <p>1: <span id="greeting">Greeting</span></p>
</div>

Javascript

$('#hello').on('click', function() {
    $('#greeting').text('Hello');
});
$('#bye').on('click', function() {
    $('#greeting').text('Bye');
});

JSFIDDLE

ObbyOss
  • 357
  • 1
  • 2
  • 14

1 Answers1

0

So my guess would be that you're not properly loading JQuery, I pasted this code verbatim into a rails app I had open that had JQuery loaded and it worked perfectly. So just load JQuery and you should be good to go

Community
  • 1
  • 1
Zubatman
  • 1,235
  • 3
  • 17
  • 34