Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 73935

How do i set a draggable attribute for my list element using javascript? [duplicate]

$
0
0

This question already has an answer here:

I want to set the draggable attribute of my list item to be true every time the button is clicked but theres an error.

const startDrag = function(){
    const li = document.getElementsByClassName('newLi')
    li.setAttribute('draggable', "true");
    startDraggable();
}

Error

TypeError: li.setAttribute is not a function

Viewing all articles
Browse latest Browse all 73935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>