The vehicles equipped with computing devices can provide computing services in vehicular fog networks, thereby reducing latency and improving system efficiency. Hence, we face with the problem of how to select vehicles for the computation offloading of the task. In this paper, we jointly consider the delay and cost, and study the resource allocation problem of multivehicles users. First of all, we construct a hierarchical offloading model, use mathematical method to construct consumption function of the system, and generate a convex optimization problem with inequality constraints. Then, we use Lagrange method to solve the problem and develop a low‐complexity algorithm to select vehicles, optimize the offloading ratio, and reduce the consumption of the system. Numerical results show that the algorithm has a fast convergence rate and good performance.