I have a CMS with a form-module, which generates an awful markup, that makes it absolutely impossible to style. The form objects and elements is nested in an ungodly amount of tables, rows and cells.
I'm working on filtering out all the elements I need through javascript, put them in an array, and create new frontenddeveloper-friendly markup using these elements.
Inputfields, legends and fieldsets is no problem - but I have a problem filtering my labels. My labels are either wrapped like this: <tr><td>Label</td></tr>
or <tr><td><b>Label</b></td></tr>
- I need to filter these out, and put them in an array.
Is there a simpler way to check, if my td contains a pure string, and not an input or some other html element, other than using regex?
var regex = new RegExp(???);
jQuery("td").each( function() {
if(jQuery(this).has("b") || regex.test(jQuery(this).text()))
{
// Do stuff here
}
}
Thanks in advance