Using Is it possible to add "class" to dynamic elements. In the below example I have written it in document ready. I want to do it for elements which will be dynamically added to have the "class" name set to "someclassname"
$.find("input[type=text],select").addClass("someclassname");
I know we can use delegate method to add events for dynamic elements. But is it possible to add class name dynamically ?
I am doing below in my code to add "focus" event. But I want to set default class while the elements are dynamically rendered in the UI.
$( "form" ).on("focusin","input[type=text],select", function() {
$(this).addClass('selected');
}).on("focusout","input[type=text],select", function() {
$(this).removeClass('selected');
});