Using the theory of electrical network, we first obtain a simple formula for the number of spanning trees of a complete bipartite graph containing a certain matching or a certain tree.Then we apply the effective resistance (i.e., resistance distance in graphs) to find a formula for the number of spanning trees in the nearly complete bipartite graph G(m, n, p) = Km,n − pK2 (p ≤ min{m, n}), which extends a recent result by Ye and Yan who obtained the effective resistances and the number of spanning trees in G(n, n, p). As a corollary, we obtain the Kirchhoff index of G(m, n, p) which extends a previous result by Shi and Chen.