【发布时间】:2020-07-02 22:26:22
【问题描述】:
我正在使用 CakePHP 3,让我告诉你我想要做什么,是使用屏幕宽度条件在 div 中显示蛋糕元素,它会引发以下错误 Uncaught SyntaxError: Unexpected identifier。我已经告诉你,语法没有任何反应,没有逗号、句号等。我错过了。
我需要知道的是将元素助手放入jquery中的正确方法这个:<?= $ this->element('Search/Legislacion/form-search-legis') ?>
<script>
$(document).ready(function(){
var width = $(document).width(),
search_form_legis = "<?= $this->element('Search/Legislacion/form-search-legis') ?>";
// console.log(width);
if(width >= 576){
$('#searchDesktop').html(search_form_legis);
}
});
</script>
【问题讨论】:
-
你的语法看起来是正确的,所以如果你没有得到想要的输出,那么你的 PHP 函数可能有问题
$this->element() -
正是,这就是为什么我问是否有人知道在 jquery 中放置等效函数的正确方法
标签: javascript php jquery cakephp-3.x