Failed to Execute querySelectorAll on Document. How to fix?

梦想的初衷 提交于 2019-12-06 06:45:22

问题


What I'm doing:

I have links generated from a PHP array which produce it's own unique ID which should point to it's own modal (popup window) div which has a matching ID to the link ID. The modals are also auto generated using a PHP array. I am receiving this error, which I am very unfamiliar with (noob). Not sure how to fix. The modal isn't working and I am using Foundation 5's reveal plugin.

PHP LINK ARRAY:

          //more code above 

              if ($track->lyrics != null) { // If lyrics field isn't empty
                  $html .= '<a href="#" class="lyricCLicked" data-reveal-id="' . $track->id . '">Lyrics</a>';                                                                                       
                  $numTracksContainingLyrics++;  
                  foreach ($track as $value) {
                     $lyricsArray[$track->id] = $track->lyrics;
                   } 
        } 

MODAL DIV ARRAY

foreach ($lyricsArray as $key => $value) {
$lyricModal = '<div id="' . $key .'" class="reveal-modal" data-reveal>';
$lyricModal .= $value;
$lyricModal .= '<a class="close-reveal-modal">&#215;</a>';
$lyricModal .= '</div>';

echo $lyricModal; 

}

The Results are being written to HTML source. So, the arrays are working and generating. It's just giving me this "Failed to Execute querySelectorALl on Document : #1042 is not a valid selector. By the way, "1042" is one of the unique IDs being generated in case you were wondering.


回答1:


querySelectorAll doesn't like number-only (or leading-digit) ids. There is a discussion here. If possible, I would add some letters in front of the numbers.



来源:https://stackoverflow.com/questions/23898873/failed-to-execute-queryselectorall-on-document-how-to-fix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!