javascript - Remove texts inside a span containing other tags -


i have span need rid og texts in side:

<span class="filter_column filter_date_range">from <input type="text" class="date_range_filter form-control" id="applicationlist_range_from_6" rel="6" value="from"></input> <input type="text" class="date_range_filter form-control" id="applicationlist_range_to_6" rel="6" value="to"></input></span> 

how can remove text "from" , "to"?

thanks

you can filter text nodes out , remove them:

$('.filter_date_range').contents().filter(function() {      return this.nodetype === 3; // filter text nodes  }).remove();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <span class="filter_column filter_date_range">from <input type="text" class="date_range_filter form-control" id="applicationlist_range_from_6" rel="6" value="from"></input> <input type="text" class="date_range_filter form-control" id="applicationlist_range_to_6" rel="6" value="to"></input></span>

the advantage of approach event handlers attached other elements aren't affected.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -