I need to get the previous element of an element found by using "contains" - prev and prevAll('span') aren't working. Any ideas? Thanks!
<script>
$(document).ready(function(){
$("label:contains('Group')").prev().addClass("spMargin");
});
</script>
<span class="radio"></span>
<label>Travel</label>
<span class="radio">(need to add class to this element!)</span>
<label>Group</label>
Using .prev() works for me. See http://jsfiddle.net/tT9Qu/
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