jquery - Get the next span with class -


i have following html structure every <select> object in page:

<div class="clspropertydiv clspropertyid_16 ">         <span class="inputtitle">you can select multiple items</span><br>         <select id="select_16" multiple="multiple" style="display: none;">             <option class="" value="2699" id="opt_2699">rusian </option>             <option class="clsoptionselected" value="2700" id="opt_2700">english </option> // take text             <option class="" value="2702" id="opt_2702">hebrew</option>         </select>          <div class="ms-parent  multipleselection" multiple="multiple">             <button type="button" class="ms-choice">                 <span class="spnmulti"></span> // insert here.                 <div class=""></div>             </button>                  </div>     </div> 

i need selected text , insert to: <span class="spnmulti"></span>

this trying do:

$('.selectoptions option').each(function() {             if ($(this).hasclass('clsoptionselected') {                 var selectedtext = $(this).text();                 $(this).next('.spnmulti').text("selectedtext ");              }         }); 

the .spnmulti don't childen of selectoptions. need call parent div , after find spnmulti.

example:

$(this).closest('.clspropertydiv').find('.spnmulti').text(selectedtext); 

and add class select "selectoptions", in selector, use: "$('.selectoptions option')" , not have .selectoptions class in select.


Comments