How does js prompt Uncaught TypeError to solve it?

error prompt:
Uncaught TypeError: autopbn.getAttribute is not a function at exauto_ajax_page.js?s1m:10

var autopbn = $("autopbn");
var nextpageurl = autopbn.getAttribute("rel").valueOf();//Uncaught TypeError: autopbn.getAttribute is not a function at exauto_ajax_page.js?s1m:10

getAttribute is a native method, and autopdn is a jquery object, so you cannot call a native method. Use attr ("rel")


it's very clear upstairs.
autopbn is a jQuery object, so naturally you can only use the jQuery method. In this article, it is .attr ('rel')
getAttribute is the operation method of DOM object. If you must use it, you can do the following

var $autopbn = $('autopbn');
var nextpageurl = $autopbn[0].getAttribute('rel').valueOf();

add $ to the variable, indicating that this is a jQuery object, which is different from the DOM object

Menu