我尝试从data属性获取值并将其传递给java脚本变量,但它给出了未定义的值
$(document).on("click","#edit_cust",function(){
var customer_id=$(this).data("id");
var customer_name=$(this).data("name");
var customer_phone=$(this).data("phone");
var customer_addr=$(this).data("mail");
var customer_mail=$(this).data("phone");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='btn-group' role='group' >
<a id="edit_cust" data-target="#edit" data-toggle="modal"><button
type='button' class='btn btn-primary btn-sm' data-id="<?php echo
$customer["cus_id"]; ?>" data-name="<?php echo $customer["cus_name"]; ?>"
data-phone="<?php echo $customer["cus_phone"]; ?>" data-addr="<?php echo
$customer["cus_address"]; ?>" data-mail="<?php echo $customer["cus_mail"]; ?
>"><span class="fas fa-user-edit edit_data" aria-hidden='true'></span>
</button></a>
</div>
答案 0 :(得分:1)
所有这些数据属性都存在于内部public static Function<Integer, Double> tariff = t -> {
if (t = 500) {
t * t;
} else {
t + t;
}
};
中,因此请在单击的元素内获取button
。
button