Frontend Development

How can i JS click on copy li tags text elements with each?

Submitted by theabuzer, , Thread ID: 94355

Thread Closed
04-07-2018, 08:00 PM
This post was last modified: 05-07-2018, 03:24 PM by theabuzer
#1
Hello guys,

Sorry first my english is little.



I have in my project 4 li tags (updated when new data is adding in the database)



I want to click mouse button on copy every li tags but dont make it. My Js skill is basic.

Code:
<ul>
<li>1. yaz</li>
<li>2. yaz</li>
<li>3. yaz</li>
<li>4. yaz</li>
</ul>

my li tags updated when new data is adding in the database.

Thank you for helping

updateee... no one knows? ?

,I need help

thank you.

RE: How can i JS click on copy li tags text elements with each?

#2
Err not too sure what you want, but here's my suggestion. Install some jQuery and then read this: https://api.jquery.com/click/

Remember, if its a link use a, if its a javascript action then use button. Therefore, you want to do something like this


Code:
<ul id="my_list">
<li><button>1. yaz</button></li>
<li>Etc</li>

</ul>

<script>

$( "#my_list > li > button" ).click(function() {

      $_this = $(this);

     //do something.... like...
     $_this.addClass("hot-pink");


});

</script>

RE: How can i JS click on copy li tags text elements with each?

#3
Code:
<script>
var tagsLi = document.getElementByTagNameNS('li');

for (const li of tagsLi) {
li.onclick = function() {
enter your code after li element has been clicked
}
}
</script>

Users browsing this thread: 1 Guest(s)