jQuery的获取特定的选项标记文本,并把动态变量的值 [英] jQuery get specific option tag text and placing dynamic variable to the value
本文介绍了jQuery的获取特定的选项标记文本,并把动态变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$('#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);
}
});
});
我有一个问题就从阿贾克斯将返回的变量的值。 $ GET = $(#UserTypeDropdown选项[值='$临时'])文本()。我该如何解决呢?请帮助..这个问题是连接: jQuery的获取特定的选项标记文字
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
推荐答案
更改此:
$get = $("#UserTypeDropdown option[value = '$temp']").text();
要:
$get = $("#UserTypeDropdown option[value='"+$temp+"']").text();
您也可以使用过滤器
方法:
$("#UserTypeDropdown option").filter(function() {
return this.value === $temp;
}).text();
这篇关于jQuery的获取特定的选项标记文本,并把动态变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文