JavaScript
1. Get by name: document.getElementByName("name").value;
2. Get through id: document.getElementById("id").value;
3. Get through the class: document.getElementsByClassName("class").value;
4. Get the value of id="querySelector" in the document: document.querySelector("#querySelector").value;
jQuery
$(this)
$(event.target)
both can represent the current operation, the latter event parameter needs to be declared outside, as shown
in the figure: shortcuts can be used in jQuery. The
var id = ((( (event.target).closest('tr').find('.delete1')).text();
means to get the nearest "tr" element of the current operation and find the class name "delete" in this "tr" element "And get its value assigned to id
closest() : 表示从元素本身开始,逐级向上级元素匹配,并返回最先匹配 的元素,就是最近的一个父元素
find() : 表示搜索所有与指定表达式匹配的元素。这个函数是找出正在处理的元素的后代元素的好方法。
text() : 表示取得所有匹配元素的内容。
Attachment: jQuery api quick reference form https://jquery.cuishifeng.cn/index.html