Possible to use css function to validate css rules?
See original GitHub issueIs it possible to use .css to validate some basic inline rules to see if they are valid?
var tree = $("<div><span></span></div>");
tree.find('span')
.css("background-color","#eee");
console.log(tree); // span changed
tree.find('span')
.css("background-color","blaahhhhcolor");
console.log(tree); //no change to span
tree.find('span')
.css("background-colaar","black");
console.log(tree); //no change to span
Compare both before and after and see if there has been an inline style attached, if there is it is valid?
If not would it be possible to add some type of callback to CSS to suggest the given rules are valid? I know jQuery isn’t a linter but in my case and possibly others this may suffice.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
valid - CSS: Cascading Style Sheets - MDN Web Docs
This pseudo-class is useful for highlighting correct fields for the user. Syntax. :valid. Examples. Indicating valid and invalid form fields.
Read more >CSS Validator User Manual - Jigsaw - W3C
When using the basic interface, the validator will check the compliance against CSS 2.1, which is the current CSS technical recommendation. It will...
Read more >Form Validation UX in HTML and CSS
Perhaps the easiest possible validation on a form you can do is use the required attribute to require a field.
Read more >WebD2: Validating Your CSS - University of Washington
Validate a Sample Page · Open the sample page with invalid CSS . · View the web page's source code. · Save the...
Read more >CSS Validator
Validate your CSS files using our free css validator. When using this tool, you'll find errors and warnings that may need to be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can just check
background-color
after the change and if its value is different than what you set it to it means the rule was invalid.If you want something more, that’s more a job for a plugin; this is way too specific to be included in jQuery Core.
Thank you. This could be achieved without jQuery in that case.
Here’s my basic function if it helps anyone.