What the books do is say, "A function from A to B is a subset $F$ of AxB such that for every x in A there is a unique y in B such that $(x,y)\in F$." But if that is all you say, then two functions can be equal even if they have different codomains, which the authors of these same textbooks clearly don't intend if they ever mention surjections, bijections or inverse functions. There's an easy fix, which is to define a function to be an ordered triple consisting of A, B and the subset of AxB, but almost no books do this. (I'm talking here about introductions to undergraduate-level mathematics rather than books about axiomatic set theory.)
What the books do is say, "A function from A to B is a subset $F$ of AxB such that for every x in A there is a unique y in B such that $(x,y)\in F$." But if that is all you say, then two functions can be equal even if they have different codomains, which the authors of these same textbooks clearly don't intend if they ever mention surjections, bijections or inverse functions. There's an easy fix, which is to define a function to be an ordered triple consisting of A, B and the subset of AxB, but almost no books do this. (I'm talking here about introductions to undergraduate-level mathematics rather than books about axiomatic set theory.)