javascript - jQuery prepend() to Elements that contain Divs -


i trying prepend() div each contains @ least 1 div. similar works:

if ($('.tooltip-item').children('div').size() > 1) { $('.tooltip-item').prepend('<div class="star">*</div>'); } 

my html set this

<a id="filteritems" class="tooltips" href="#">xbox     <span class="tooltip-container">         <div class="tooltip-item">controller</div>         <div class="tooltip-item">console             <div class="filter-item">in stock</div>             <div class="filter-item">pre-order</div>         </div>     </span> </a> 

in example prepend() "console" each method have tried end div each item or no item. how can prepend "console" div contains divs?

loop through each element, otherwise take first element,

$('.tooltip-item').each(function () {     if ($(this).children('div').size() > 1) {         $(this).prepend('<div class="star">*</div>');     } }); 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -