How to get the value of an element at the previous level

Code:
< input id= "number0" name= "number" type= "text" value= "1" class= "number_text" >
< href= "- sharp" onclick= "addNum (this)" id= "add0" class= "jia" > + < / >

function addNum (a) {

alert(a.prev("input").text());

}
because the a tag will be converted on the web page, I remove the a
question: I want to get the value of input, but this doesn"t work. What value should be passed in, addNum () parentheses, and how to get the upper-level element

Mar.06,2021

this does not have a prev () method
$(this) only.

in jQuery, it is not recommended to use onclick, to directly use element selector operations:


jsjQuery

// <a><b1 id="b1"/><b2 id="b2"/></a>

alert(document.getElementById("b2").previousSibling.id); // "b1"
Menu