I'm looking for a way to allow users to input CSS styles and have those styles applied to the last selected element, which is determined by the "rangeselector" variable. Currently, the code selects the correct element, but only the first CSS rule is being applied.
For example, if a user inputs "background: blue; color:red;", only the background property gets applied.
The function successfully iterates through the array.
function customCss(){
css = $("input.css").val();
if(css.length < 10){
alert("Please enter valid CSS");
}else{
cssArray = css.split(";");
counter = 0;
cssArray.forEach(function(){
var ruleSplit = cssArray[counter].split(":");
target = $("[content_child=" + rangeselector + "]");
target.css(ruleSplit[0] , ruleSplit[1]);
counter = counter + 1;
});
}
}
If you have any insights into the issue, or a better approach to accomplish the same goal, I would appreciate your suggestions.
Thank you