Uncaught TypeError: Cannot read property 'toLowerCase' of undefined

前端 未结 6 1539
星月不相逢
星月不相逢 2020-12-05 09:30

I\'m getting this error and it is originating from jquery framework. When i try to load a select list on document ready i get this error. I can\'t seem to find why i\'m gett

6条回答
  •  自闭症患者
    2020-12-05 09:52

    I had the same problem, I was trying to listen the change on some select and actually the problem was I was using the event instead of the event.target which is the select object.

    INCORRECT :

    $(document).on('change', $("select"), function(el) {
        console.log($(el).val());
    });
    

    CORRECT :

    $(document).on('change', $("select"), function(el) {
        console.log($(el.target).val());
    });
    

提交回复
热议问题