javascript - attr value sowing undefined in console -


i trying data-icons value shows undefined in console.

my codes are

<ul class="list-icons" data-icons="star"> 

js files

var icon = $('ul.list-icons li').attr('data-icons'); console.log(icon); 

it shows undefined

you're selecting li, attribute on ul. remove li.

var icon = $('ul.list-icons').attr('data-icons'); // no li here -------------^ console.log(icon); 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -