Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
118
rated 0 times [  120] [ 2]  / answers: 1 / hits: 39376  / 7 Years ago, tue, january 31, 2017, 12:00:00

With JQuery, click event of the any item in the page can be captured as below.



$(document).click(function(event){
// event.target is the clicked element object
});


How to do the same with Vue.js?


More From » vue.js

 Answers
2

  1. Create div as top node, right after <body>

  2. Make it main container and mount VueJS on it.

  3. <div id='yourMainDiv' @click='yourClickHandler'>

  4. In your VueJS <script> part use it:



methods: {
yourClickHandler(event) {
// event.target is the clicked element object
}
}

[#59140] Sunday, January 29, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaitlynnb

Total Points: 402
Total Questions: 96
Total Answers: 109

Location: Trinidad and Tobago
Member since Fri, May 8, 2020
4 Years ago
kaitlynnb questions
;