基于php值的onload触发点击

我有以下代码:

<a href="#x_table" {{ $service->specie == 'x' ? 'onload="click()"' : '' }} 
class="{{ $service->specie == 'x' ? 'active' : '' }}" 
id="xEditNavigator">PlaceHolder</a>

我有{{ $service->specie == 'x' ? 'onload="click()"' : '' }}主播。

它应该工作,但是不行,还有其他办法吗?

路易斯·费利佩·德·耶稣·穆诺兹

在您的HTML中:

<a href="#x_table" class="{{ $service->specie == 'x' ? 'active' : '' }}" 
id="xEditNavigator">PlaceHolder</a>

然后,在 <body>

<script>
      @if($service->specie == 'x') 
           document.getElementById('xEditNavigator').click();
      @endif
</script>

另外,如果您使用的是jQuery:

<script>
    @if($service->specie == 'x') 
        $(document).ready(function(){
             $('#xEditNavigator').click()
        })
    @endif
</script>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章