Deep learning-based image watermarking algorithms have been widely studied as an important technology for copyright protection. These methods utilize an end-to-end architecture with an encoder, a noise layer and a decoder to make the watermark robust to various distortions. However, recent algorithms present unsatisfactory visual quality and robustness against JPEG compression, which is the most common image processing operation but is non-differential thus cannot be directly included in the noise layer. To address this limitation, this study proposes a novel enhanced attention-based image watermarking algorithm with simulated JPEG compression, which leverages the channel and spatial attention mechanism to facilitate watermark embedding and simulates JPEG compression with a suitably designed function. Precisely, we design a differentiable rounding function based on the Fourier series to replace the quantization process in JPEG compression, which overcomes the non-differentiability of JPEG compression and can be incorporated in the training process. In addition, we propose an enhanced dual attention module in the encoder, which combines channel and spatial attention to improve the performance of our model. The channel attention guides the encoder to fuse the watermark into more important channels and the spatial attention further helps to embed the watermark into regions with more complex textures. The experimental results show that our method generates high quality watermarked images, with PSNR over 50 when no noise is applied. Compared with current methods, our model achieves stronger robustness to JPEG compression, with bit accuracy over 99% under the JPEG compression with quality factor of 50. Besides, the proposed framework also exhibits excellent robustness for a variety of common distortions, including cropout and dropout.