Menu
×
×
Correct!

Exercise:

Provide the correct code so that the <div> element changes color when right clicked.

ALSO, add code so that the default drop down menu that appears when you right click a web page, is not shown.

<div id="app"> <div v-on:click.right.prevent="changeColor" v-bind:style="{backgroundColor:'hsl('+bgColor+',80%,80%)'}"> <p>Press right mouse button here.</p> </div> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { bgColor: 0 } }, methods: { changeColor() { this.bgColor+=50 } } }) app.mount('#app') </script>

Not Correct

Click here to try again.

Correct!

Next ❯
<div id="app">
  <div v-on:click.="changeColor"
      v-bind:style="{backgroundColor:'hsl('+bgColor+',80%,80%)'}">
    <p>Press right mouse button here.</p>
  </div>
</div>

<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
  const app = Vue.createApp({
    data() {
      return {
        bgColor: 0
      }
    },
    methods: {
      changeColor() {
        this.bgColor+=50
      }
    }
  })
  app.mount('#app')
</script>

    
  




Log in to keep your progress
Sign up to keep your progress

Completed 0 of 54 Exercises:

VUE Get started
VUE Directives
VUE Methods
VUE Computed
VUE Watchers
VUE Scaling up
VUE Components
VUE Slots
VUE Refs
VUE Lifecycle hooks
VUE Provide/Inject
VUE Routing
VUE Animations
VUE Build

×

Reset the Score?

This will reset the score of ALL 54 exercises.

Are you sure you want to continue?



×

Congratulations!

You have finished all 54 VUE exercises.

Share your score: