Change div text on click
Change div text on click
I have been trying to work out how to change the text inside the div when the button is clicked in the same fashion as the button text is responding.
jsfiddle
I tried changing the if / else to act on the div rather than the button like so -
- if ($(".stileone").text() === 'Yellow Box') {
- $(this).text('Red Box');
- }
- else {
- $(this).text('Yellow Box');
- }
but it did not work. How might I change the text in both the button and the div on click please. Any clues would be appreciated thanks.
ps - I could get it to change the text inside the div when the onclick was acting on the div
jsfiddle