Tomando el texto de la opción de selección de la opción de selección fantasia [cerrado]
Frecuentes
Visto 165 equipos
0
<select id="from" name="from" required="required" class="fancified">
<option value="1">abc</option>
<option value="2">fgh</option></select>
<div class="trigger">abc</div>
<select id="to" name="to" required="required" class="fancified">
<option value="1">yuo</option>
<option value="2">ioj</option></select>
<div class="trigger">yuo</div>
since fancybox is applied to select. I need to get Penang selected option.
which can be done doing this:
$('trigger').text();
my problem is, I have another drop down using fancified. When i $('trigger').text(); I'm getting text from both. How can I separate it, I need both of them separately.
4 Respuestas
1
Jquery is probably returning the first element it finds that matches the selector $('.trigger')
What you will need to do is grab the element being clicked and then maybe use the sibling selector
p.ej
$('#from').on('change', function(event){
$(event.target).siblings('.trigger').text()
})
Respondido 12 Feb 14, 08:02
0
Prueba esto:
$('.fancified').change(function() {
var text = $(this).next().text();
});
También necesitas usar .
to target class, so you need $('.trigger')
en lugar de $('trigger')
Respondido 12 Feb 14, 08:02
0
Prueba esta
$(".fancified option:selected").text();
Respondido 12 Feb 14, 08:02
0
you could wrap each of the fancy drop downs in a div and then call the child trigger e.g.
<div id="trg1"> ... fancy1 ...</div>
<div id="trg2"> ... fancy2 ...</div>
You can then select using
$('#trg1 trigger').val()
$('#trg2 trigger').val()
Respondido 12 Feb 14, 08:02
I already have id in val so I cannot do that - Jyoti
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas jquery html or haz tu propia pregunta.
yes, for example abc and cdf is selected from two. Then I'm getting abccdf like this. How can I seperate it ? - Jyoti
show both selects in your code, i can see only one.. - zzlalani