简体   繁体   中英

How to search for text that comes from DOM

Here is how it should work. I have an application where you have to select a sport activity. At the moment I have a function setActivityType(String: ActivityName) that is going to set the value in my database. Now what I want to do is when I click on that button is should highlight the clicked button. I want to do this my searching in the dom the ActivityName passed in before and select it so I can change the style of it. This is how each sport button is made :

<div class="type" onClick="setActivityType('Volley')">
            <i class="fas fa-volleyball-ball"></i>
            <p>Volley</p>
        </div>

So how could I search for the <p>Volley</p> value?

我想出用event.target来做这件事,它将获得所有的 dom 信息,然后我想出了如何操作它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM