javascript - how can i find closest span? -


let's having fallowing html structure-

<div data-theme="a" class="ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-a">     <span class="ui-btn-inner ui-btn-corner-all">         <span class="ui-btn-text">select one</span>         <span class="ui-icon ui-icon-arrow-d ui-icon-shadow">         </span>     </span>     <select onchange="selectstate(this,'addr_ship_state')" id="addr_ship_state" name="addr_ship_state">          <option>hi</option>         <option>hello</option>         <option>how</option>         <option>are</option>         <option>you</option>     </select>    </div>   

what trying on change of select box, take text of selected option , place inside span(replace select one data) having class name ui-btn-text

below code ahve tried without luck

function selectstate(id,stateid){ var selectedstate = $("#"+stateid+" option:selected").text(); $(id).closest("ui-btn-text").text(selectedstate); } 

please suggest me how can this..

.closest()ref progress dom won't down .parents() (btw, didn't add . (dot) class search typo)

here try:

$(id).parent().find(".ui-btn-text").text(selectedstate); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -