-1
如何在yii 2.0的mi視圖中添加jquery腳本?我在尋找,我發現這個命令jquery腳本yii2
$this->registerJs('$(function()
{
$("#wizard").steps({
headerTag: "h2",
bodyTag: "section",
transitionEffect: "slideLeft"
});
$("#wizard-vertical").steps({
headerTag: "h2",
bodyTag: "section",
transitionEffect: "slideLeft",
stepsOrientation: "vertical"
});
});', 3);
和輸出是這樣的,一個JavaScript
<script type="text/javascript">$(function()
{
$("#wizard").steps({
headerTag: "h2",
bodyTag: "section",
transitionEffect: "slideLeft"
});
$("#wizard-vertical").steps({
headerTag: "h2",
bodyTag: "section",
transitionEffect: "slideLeft",
stepsOrientation: "vertical"
});
});</script>
的問題是我需要把它作爲一個jQuery腳本這樣
<script>
$(function()
{
$("#wizard").steps({
headerTag: "h2",
bodyTag: "section",
transitionEffect: "slideLeft"
});
$("#wizard-vertical").steps({
headerTag: "h2",
bodyTag: "section",
transitionEffect: "slideLeft",
stepsOrientation: "vertical"
});
});
</script>
但我不知道如何打印JQuery腳本,有人知道嗎?
2幾乎相當。什麼似乎是問題? – MasterAM 2014-12-27 16:49:16
這個問題沒有意義.... – 2014-12-28 11:42:23
jQuery是JS,所以它的語法正確。如果它不工作,請確保jQuery文件已加載,並且在jQuery加載後執行JS。 – 2014-12-28 12:41:27