Results 1 to 2 of 2
Sep 6, 2011, 05:49 #1
jquery remove span wrapping input
I want to use jquery to make sure that my HTML forms have the correct structure and classes.
What I want:
<form class="myclass"> <label class="label-class"><span class="there_is_supposed_to_be_a_span_here">Label</label> <input class="input-class" type="text" /> </form>
This is what I have so far:
jQuery('form').addClass('myclass'); jQuery('label').addClass('label-class'); jQuery('input:text').addClass('input-class'); //now remove unwanted spans var inp = jQuery("input"); var clean = jQuery(inp.outerHTML); jQuery("span", clean).remove();
How can I do this??Finding beauty in the simple.
Sep 6, 2011, 10:44 #2
- Join Date
- Oct 2009
- London, UK
- 1 Post(s)
- 0 Thread(s)
Erm, not 100% sure what you are trying to achieve.
So some labels and inputs are wrapped in spans and some are not? You want to find the ones that are and remove the spans? Is that correct?
How about putting the relavent html into a variable and removing the spans using a regex? Then appending the variable data to the DOM?