Jquery 未捕获错误语法错误,无法识别的表达式:li/label

Jquery Uncaught Error Syntax error, unrecognized expression: li/label

我想插入一个cookie通知栏。现在在一个旧的通讯页面上我得到这样的错误:

Uncaught Error: Syntax error, unrecognized expression: li/label

新闻通讯中的以下代码是

if( document.addEventListener ) document.addEventListener( 'DOMContentLoaded', cmxform, false );

    function cmxform(){
      // Hide forms
      $( 'form.cmxform' ).hide().end();

      // Processing
      $( 'form.cmxform' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){
      var labelContent = this.innerHTML;
      var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
      var labelSpan = document.createElement( 'span' );
        labelSpan.style.display = 'block';
        labelSpan.style.width = labelWidth;
        labelSpan.innerHTML = labelContent;
      this.style.display = '-moz-inline-box';
      this.innerHTML = null;
      this.appendChild( labelSpan );
      } ).end();

      // Show forms
      $( 'form.cmxform' ).show().end();
    }

    //function to check empty fields

    function isEmpty(strfield1, strfield2) {

    strfield1 = document.forms.newsletter_subscribe.nome.value 
    strfield2 = document.forms.newsletter_subscribe.email.value

      if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
      {
      alert("Please insert your name!")
      return false;
      }

      if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
      {
      alert("Please insert a valid Email!")
      return false;
      }

      return true;
    }

    //function to check valid email address
    function isValidEmail(){
      validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
      strEmail = document.forms.newsletter_subscribe.email.value;

     // search email text for regular exp matches
      if (strEmail.search(validRegExp) == -1) 
     {
      alert('Email not valid! Please retry!');
      return false;
      } 
      return true; 
    }

    //function to check privacy
    function Privacy()
     {
     if (document.forms.newsletter_subscribe.checkbox.checked==false)
      {
      alert('Please accept the privacy conditions!');
      return false;
      }
      return true;
    }

    //function that performs all functions, defined in the onsubmit event handler

    function check(){
    if (isEmpty()){
            if (isValidEmail()){
                if (Privacy()) {
              return true;
            }
        }
    }
        return false;
    }

    //**********************************************************************************************
    //function to check empty fields unsubscribe form

    function isEmptyEmail(strfield1) {

    strfield1 = document.forms.newsletter_unsubscribe.email.value

      if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
      {
      alert("Please insert a valid Email!")
      return false;
      }


      return true;
    }

    //function to check valid email address
    function isValidEmailCancel(){
      validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
      strEmail = document.forms.newsletter_unsubscribe.email.value;

     // search email text for regular exp matches
      if (strEmail.search(validRegExp) == -1) 
     {
      alert('Email not valid! Please retry!');
      return false;
      } 
      return true; 
    }

    //function that performs all functions, defined in the onsubmit event handler

    function check_unsubscribe(){
    if (isEmptyEmail()){
            if (isValidEmailCancel()){
              return true;
        }
    }
        return false;
    }

删除新资源时,那个通讯脚本就可以了。但是,当使用新的 jQuery 资源时出现此故障。

如果您想在 jQuery 中连接多个选择器,发现您使用了错误的语法

$( 'form.cmxform' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){

应该变成:

$( 'form.cmxform' ).find( 'li, label' ).not( '.nocmx' ).each( function( i ){

这意味着您正在寻找您选择的 DOM 范围内的任何 li 或 label 标记 ('form.cmxform')