I have this variable and i want to add a class to it. I tryed this method, but this defenetly is not working
var someVar = '<i class="firstClass"></i>';// Html Markup to be used later.
someVar.addClass('secondClass');
I need a different method to adding a new class to the html markup.
Thanks
You can only use addClass on a HTML element so you need to set your variable to be a DOM element (e.g. $('<i>')
):-
var someVar = $('<i>', {'class': 'firstClass'});
someVa.addClass('secondClass');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With