The moisture with salt ions adsorbed on the mineral soil surface is crucial to the cohesion process when the media is exposed to marine or coastal environments. However, the impact of salinity on the cohesion of soils is not well studied at the nanoscale. In this study, the salinity effect was investigated by studying the wettability and capillary force of NaCl solutions on quartz substrates via a molecular dynamics-based approach. Besides, a new visualization method was proposed to measure the contact angle of liquid droplets from the aspect of nanoscale. The results indicated that salt ions can weaken the wettability of the liquid on the quartz surface and inhibit the capillary force. Compared with water, the liquid with a 10% NaCl solution can achieve a capillary force reduction of around 70%, resulting in a detrimental effect on the cohesion of soils. Overall, this study enhanced the understanding of the nanoscale salinity effect on the cohesion process and provided insights into the modification of the mechanical properties of soils from the aspect of nanoscale.