0
I have the following HTML structure:
<div class="ui fluid search dropdown procuraAluno selection multiple active visible">
<select name="ci_direcionado" id="cisOptions" multiple="">
<option value=""></option>
</select>
<i class="dropdown icon"></i>
<input class="search" autocomplete="off" tabindex="0" >
<span class="sizer" style="">Anderson Amorim</span>
<span class="sizer"></span>
<div class="text filtered"></div>
<div class="menu transition visible" tabindex="-1" style="display:
block !important;">
<div class="message">No results found.</div>
</div>
How do I get the text from the first span? I’ve tried several ways, for example:
$(".procuraAluno").closest('.sizer').first().change(function(){
console.log($(".procuraAluno").next().text());
});
However, to no avail.
Remembering that the creation of 2 span is inherent in my will, the very template that creates it.
Grateful.
Cool! It worked, but I still have a doubt, I’m trying to use this same structure to detect a change event and it’s going wrong :/ As follows: $('. procuraAluno'). find('. Sizer'). first(). change(Function(){ });
– Anderson Amorim
I changed the answer to "watch" the event
change
. If you want the function to be invoked by changing thespan
dynamically, you can trigger the event with the functiontrigger
.– Wesley Gonçalves
I would like to shoot when there was change in the text itself, then I did as you showed. However the change event is not triggered...
– Anderson Amorim
You are replacing
html
fortext
? If that’s it, in this fiddle I made it work.– Wesley Gonçalves