数据集的不确定值

I try to have value of data-set with JQuery, but it returns undefined value and I don't know why:

<option class="option" 
        value="<?php echo $art["id_art"]; ?>"
        data-unite="<?php echo $art["unite_lib"]; ?>" 
        data-qte="<?php echo $art["art_solde"]; ?>"
        data-perissables="<?php echo $art["perissable"]; ?>">
    <?php echo $art["lib_art"]. " périssable : ".$art["perissable"]; ?>
</option>

and with JS :

var id = $(this).find("option").val()
var qte = $(`option[value=${id}]`).data("qte");
var perissable = $(`option[value=${id}]`).attr("data-perissables")
console.log(perissable);

I tested all your proposals, maybe I did not ask my question in fact the data of the selectbox comes from my database and for each value i try to have value of "perissable".

<?php foreach($articles as $art): ?>
                                                        <?php if($art["id_type_art"] == "1"): ?>
                                                             <?php  if(!in_array($art["id_art"],$tab) ):    ?>
                                                                <option class="option" value="<?php echo $art["id_art"]; ?>" data-unite="<?php echo $art["unite_lib"]; ?>" data-qte="<?php echo $art["art_solde"]; ?>" data-perissables="<?php echo $art["perissable"]; ?>"><?php echo $art["lib_art"]; ?></option>
                                                                <?php $tab[]= $art["id_art"] ; ?>
                                                             <?php endif ?>

                                                        <?php endif ?>

                                                <?php endforeach; ?>

I tested your jqyery code, and in this line:

var id = $(this).find("option").val()

The result (id) is undefined. But I changed $(this) to $('body') and it worked. In your code $(this) is equal to window . Change your first jquery line to this:

var id = $('body').find("option").val()

Update:

If your codes are about a select box change or click event you can do this easily:

var qte = $(this).data("qte");
var perissable = $(this).attr("data-perissables")

I saw what was causing the problem. in fact there was a confusion with the datatable paggination options. so I proceeded like that to properly target the element.

$("#select-articles").on("change", function(e){
                var id = $(this).val()
                var qte = $(`option[value=${id}]`).data("qte");
                var perissable = $(this).find(`option[value=${id}]`).data("perissable");
                var url = '<?php echo base_url("index.php/Articles/get_cout_date_exp/"); ?>'})