I try:
alert($('select:eq('+$(this).index()+') option:selected').html());
alert($('select:eq('+$(this).index()+') option:selected').text());
alert( $($(this+ 'option:selected')[$(this).index()]).text() );
Code:
<html>
<head>
<title></title>
<meta charset="utf-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
// http://www.webdeveloper.com/forum/showthread.php?t=256214
// http://www.w3schools.com/jquery/jquery_ref_selectors.asp
$(document).ready(function(){
$('select').change(function(){
// alert( $('select').length); // 2
//var s = $('select option:selected');
/*
alert( $(this + ':selected').text());
alert( $($(':selected')[$(this).index()]).text());
*/
/*
var s = $(this + 'option:selected');
alert(s);
alert(s.length);
alert(s.val());
alert(s.text());
var ind= $(this).index();
alert(ind);
var el = s[ind];
var txt = $(el).text();
alert (txt);
*/
//alert($('select:eq('+$(this).index()+') option:selected').html());
//alert($('select:eq('+$(this).index()+') option:selected').text());
alert( $($(this+ 'option:selected')[$(this).index()]).text() );
//alert( $($(this+ 'option:selected')[$(this).index()]).html() );
});
});
</script>
</head>
<body>
<select>
<option value="">Lütfen bir tanesini seçin!</option>
<option value="elhamdülillah">övgü Allah'a mahsustur</option>
<option value="subhanallah">Allah, noksan sıfatlardan münezzehtir</option>
<option value="allahüekber">Allah, büyüktür</option>
</select>
<select>
<option value="">Lütfen bir tanesini seçin!</option>
<option value="la ilahe illallah">Allah'tan başka ilah yoktur</option>
<option value="maşallah">Allah ne güzel yaratmış</option>
<option value="inşallah">Allah'ın izniyle</option>
</select>
</body>
</html>
Last edited by Ayşe; 02-01-2012 at 06:34 AM.
The Time Through Ages
In the Name of Allah, Most Gracious, Most Merciful
1. By the Time,
2. Verily Man is in loss,
3. Except such as have Faith, and do righteous deeds, and (join together) in the mutual enjoining of Truth, and of Patience and Constancy.
Bookmarks