N
N
Natalya Chobot2017-07-08 21:31:15
JavaScript
Natalya Chobot, 2017-07-08 21:31:15

Why is the title not displayed when clicking on the element?

There is a list that is displayed using vue

<ul id="app">
    <li v-for="item in items">
            <p class="post" id="p1">{{ item.title }}</p>
            <p>{{ item.subtitle }}</p>
           <p>{{ item.datePostCreate }}</p>
           <p>{{ item.text }}</p>
      </li>
</ul>

There is a function that should display the contents of the p tag in alert, that is, the item.title title:
$(".post").click(function(){
                alert($(this).text());
});

Initially, there are several posts on the page, and you need to find out which post was clicked on.
Why isn't the title displayed? Please, help)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kovalsky, 2017-07-08
@nata-ponchik

Example
PS: never worked with Vue at all, all info from the VueJS events manual

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question