jQuery get specific option tag text and placing dynamic variable to the value
$('#NameDropdown').change(function(){
$.ajax({
type: "POST",
dataType: "json",
url: "http://localhost:8081/crownregency/getInfoUser.php",
data: {id: $('#NameDropdown').val(), checker: 1}, // 1 is to get user info
success:function(data){
$temp = data['Type'];
$get = $("#UserTypeDropdown option[value = '$temp']").text();
$('#UserType').attr('value', $get);
}
});
});
I have a problem with regard to placing the returned variable from ajax to the value. $get = $("#UserTypeDropdown option[value = '$temp']").text(); how do i solve this? pls help.. this question is connected to: jQuery get specific option tag text
Change this:
$get = $("#UserTypeDropdown option[value = '$temp']").text();
To:
$get = $("#UserTypeDropdown option[value='"+$temp+"']").text();
You could also use the filter
method:
$("#UserTypeDropdown option").filter(function() {
return this.value === $temp;
}).text();
也许试试这个:
$get = $("#UserTypeDropdown option[value = '" + $temp + "']").text();
链接地址: http://www.djcxy.com/p/14574.html
上一篇: 匿名功能存储的效率