【问题标题】:Adding code into weebly将代码添加到 weebly
【发布时间】:2013-05-24 04:12:45
【问题描述】:

我有这个http://jsfiddle.net/TtX7F/1/,但我不知道如何让它在 weebly 中工作。 HTML部分有效,但js仅在编辑时有效,而不是在发布时有效,我不知道将CSS放在哪里。

这是javascript

$("input").on("click", color);
$(document).ready(color);

function color() {
var shell = $("[name='shell']:checked").val(),
    thumbs = $("[name='thumbs']:checked").val(),
    result = {
        "shell": "",
            "thumbs": ""
    };

switch (true) {
    case (shell === "black"):
        result.shell = "http://liberatedinamerica.com/wp-content/uploads/2013/05/shell-black.png";
        break;
    case (shell === "blue"):
        result.shell = "http://liberatedinamerica.com/wp-content/uploads/2013/05/shell-blue.png";
        break;
    case (shell === "pink"):
        result.shell = "http://liberatedinamerica.com/wp-content/uploads/2013/05/shell-pink.png";
        break;
}

switch (true) {
    case (thumbs === "red"):
        result.thumbs = "http://liberatedinamerica.com/wp-content/uploads/2013/05/ey-thumbs-ps3-red.png";
        break;
    case (thumbs === "lime"):
        result.thumbs = "http://liberatedinamerica.com/wp-content/uploads/2013/05/ey-thumbs-ps3-lime.png";
        break;
}

$(".shell").attr("src", result.shell);
$(".thumbs").attr("src", result.thumbs);

console.log(result);

}

【问题讨论】:

    标签: javascript html css radio


    【解决方案1】:

    您可以在“嵌入”元素中添加 HTML,在主 style.css 中添加 CSS。也可以使用嵌入元素添加 Javascript。添加Javascript,你可以试试这个:

    <script> <Insert your Javascript Code here> </script>

    为避免使用过多元素,只需在 HTML 代码下方添加 Javascript 代码,如下所示:

    <html>
    <add your HTML code here>
    </html>
    <script>
    <Javascript code>
    </script>
    

    【讨论】:

      【解决方案2】:

      可以通过“嵌入代码”元素放置 HTML 代码。 CSS 可以插入到您的站点/页面/布局标题中,但请记住用&lt;style&gt;&lt;/style&gt; 将其括起来。但是您也可以在 main-style.css 上添加 CSS。 JS或JavaScript(和其他JQueries)可以放在&lt;script&gt;&lt;/script&gt;包围的页眉/页脚代码框中。

      这是最简单的解释。更详细的解释:http://www.myweeblytricks.com/2014/01/3-ways-in-editing-weeblys.html

      【讨论】:

        【解决方案3】:

        您可以将您的 js 代码添加到 weebly 文件中的 custom.js 文件中。enter image description here

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-07-13
          • 2015-09-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-08-25
          • 2010-09-12
          • 2014-04-20
          相关资源
          最近更新 更多