2015-07-22 3 views
0

Я хочу вставить панель уведомлений cookie. Теперь на старой странице новостей я получаю сообщение об ошибке, как это:Ошибка JQuery Ошибка синтаксиса, нераспознанное выражение: li/label

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 = /^[^@][email protected][^@]+.[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 = /^[^@][email protected][^@]+.[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 получите этот сбой.

+0

Ошибка говорит мне все: $ ('form.cmxform') .find ('li/label') –

+0

Да, но когда я использую последние старый jQuery.js (от м 2006) рассылка Сценарий в порядке ... –

ответ

0

Если вы хотите, чтобы сцепить более чем один селектор в JQuery найти вы используете неправильный синтаксис

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

должны стать:

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

и это означает, что вы ищете какой-либо литий или этикетку тег в области DOM, которую вы выбрали ('form.cmxform')

+0

Это решение спасибо! –

Смежные вопросы