Answers for "jquery add option if not exist"

0

jquery add option if not exist

var optionExists = ($('#columnsAvailable option[value=' + $(this).val() + ']').length > 0);

if(!optionExists)
{
    $('#columnsAvailable').append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>");
}
Posted by: Guest on March-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language