I have a problem with my JavaScript script.
I need to export a CSS style that I have set with a tool to a browser readable CSS file. A JavaScript function gets the path of the element that I change and returns something like this:
html>body>div:eq(2)>div>div:eq(1)>article>div>div>p:eq(1){text-decoration:underline;}
The path works great with as a jQuery selector, but not valid in CSS file.
I've tried to replace the :eq element by :nth-child but despite it's a valid CSS file, the style won't apply.
What am I doing wrong? How can i convert my :eq to something that css understand.
You can pass second argument flag in RegExp for global search:
new RegExp(pattern[, flags])
Use:
var regExp = new RegExp('(:eq)','g');
Working Demo
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