Ajax 文本字段:获取文本字段的 class 并更改默认值

Ajax text field: getting a class of a text field and changing the default value

目标:点击

时更改 current_category_id 的值

我希望更改值的输入标签:

 <input type="text" id="current_category_id" class="current_category_id" value="1">

按钮,此处的值根据单击的行而变化

 <button type="button" value="${cat.category_id}" class="category_sort btn float-left" data-toggle="modal" data-target="#createCategory">${cat.category_name} (${cat.category_id})</button>

此代码未定义

 $(document).on('click', '.category_sort', function (e) {
   e.preventDefault();
   var new_category_id_sort = $(this).val(); 
   document.getElementById('current_category_id').value=e.new_category_id_sort;
 );

如何修复我的 document.getElementById?

使用查询选择器

        $(document).on('click', '.category_sort', function (e) {
        e.preventDefault();
            //change value to sort group
            var new_category_id_sort = $(this).val(); 
            var a = document.querySelector('.current_category_id').value;
            document.querySelector('.current_category_id').value = new_category_id_sort;
            fetchgroup();
        });