Is there a 'not found' exception for jquery selector?

后端 未结 4 1449
孤街浪徒
孤街浪徒 2021-01-18 08:56

I just spent \'hours\' with the following scenario: (all back to the basics)

 $(\'#typo\').bind(\'click\' etc ...

I had a typo in the selec

4条回答
  •  [愿得一人]
    2021-01-18 09:48

    var element = $('#typo');
    if (element.length > 0) {
        // element exists
    }
    

    Short of that, you would have to modify the jQuery source code to get that behavior.

提交回复
热议问题