DOM class injection in PHP
- by Adam Kiss
idea
Via jQuery, I was able to mark all :first-child and :last-child elements in document (well, almost all :)) with class first which could I later style (i.e. first li in ul#navigation would be easily adressable as ul#navigation .first).
I used following code:
var $f = $('*:first-child')
$f.addClass('first');
var $l = $('body *:last-child')
$l.addClass('last');
question
Now, my question is if it's possible to do the same via php, so non-JS users/gadgets could have the same effects and additional styling and also it would be less overkill on browser.
So, is it possible to capture output, parse it as html and inject this class easily in php?