lundi 21 juin 2021

How to add element inside another element with jquery

Hey I'm trying to add <a> tag inside <li> with jquery and I'm struggling to find the right way. here is my code example :

$dropdown.find('ul').append($('<li></li>').append($('<a></a>'))
    .attr('href', $option.val())
    .attr('data-display', (display || null))
    .addClass('option ' + customClassEtay +
    ($option.is(':selected') ? ' selected' : '') +
    ($option.is(':disabled') ? ' disabled' : ''))
    .html($option.text())



Aucun commentaire:

Enregistrer un commentaire