php - 如何在 HTML 选择列表中检索选项项的属性?
问题描述
我试图获得两个值。一方面,它正在工作,但另一方面却没有。这是我的代码:
<div class="product-price">
<div class="lefts-column">
<span>₹</span>
<span id="priceval"> {{$weights[0]->price}} </span>
<input type="hidden" class="priceval1" value="{{$weights[0]->id}}" id="pro_ids">
</div>
<div class="choose-weight">
<!-- original reads <select onchange="yes(this.value,this.data)"> -->
<select onchange="yes(this.value,this.name)">
@foreach($weights as $weight)
<option id="red" name="{{$weight->id}}" data-id="{{$weight->id}}"
class="weight" value="{{$weight->price}}">
{{$weight->weight}}
</option>
@endforeach
</select>
</div>
</div>
<!--jquery function-->
<script>
function yes(pid , uid)
{
$('#priceval').html(pid);
alert(uid);
//$('#pro_ids').val(uid);
}
</script>
现在我alert
用来检查值是否被检索(然后警报什么也不显示)。
this.value
正在工作,this.name
但没有。有什么办法可以解决吗?
解决方案
推荐阅读
- python - Python:在谷歌云存储中将所有文件读取为 gcs_uri
- powershell - 脚本从 powershell ISE 工作,但不是从 powershell
- java - 进行中的重新平衡异常意外发生
- kubernetes - kubectl status.phase=运行返回错误结果
- javascript - 用 Express 为 Mongoose 编写端点函数的正确方法是什么?
- dart - 飞镖初学者需要帮助
- c# - 带有继承对象的 JsonConvert DeserializeObject
- php - 在 symfony JMS PHP 中将单个字符串属性反序列化为对象
- spock - Micronaut @Replaces 用声明式客户端
- python - 使用 unittest RuntimeError 进行异步测试