jQuery if has() selector do stuff

前端 未结 5 437
逝去的感伤
逝去的感伤 2021-01-15 05:45
  • text

http://jsfiddle.net/wZ8MC/2/

jQuery(document).ready(functi         


        
5条回答
  •  猫巷女王i
    2021-01-15 06:27

    That's because has returns a jQuery object and an object is a truthy value in JavaScript, you should use length property:

    if (jQuery('#bad-drifting').has('em').length) {
    

提交回复
热议问题