admin管理员组

文章数量:1333442

I have this / but I don't know how to get it to work in weebly. The HTML part works, but the js only works when editing, not when it's published and I don't know where to put in the CSS.

This is the 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 = ".png";
        break;
    case (shell === "blue"):
        result.shell = ".png";
        break;
    case (shell === "pink"):
        result.shell = ".png";
        break;
}

switch (true) {
    case (thumbs === "red"):
        result.thumbs = ".png";
        break;
    case (thumbs === "lime"):
        result.thumbs = ".png";
        break;
}

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

console.log(result);

}

I have this http://jsfiddle/TtX7F/1/ but I don't know how to get it to work in weebly. The HTML part works, but the js only works when editing, not when it's published and I don't know where to put in the CSS.

This is the 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./wp-content/uploads/2013/05/shell-black.png";
        break;
    case (shell === "blue"):
        result.shell = "http://liberatedinamerica./wp-content/uploads/2013/05/shell-blue.png";
        break;
    case (shell === "pink"):
        result.shell = "http://liberatedinamerica./wp-content/uploads/2013/05/shell-pink.png";
        break;
}

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

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

console.log(result);

}

Share Improve this question edited Jul 2, 2022 at 9:51 Jonas 129k102 gold badges327 silver badges405 bronze badges asked May 29, 2013 at 3:00 DowensDowens 231 silver badge4 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 3

You can add the HTML in the 'Embed' Element and the CSS in your main style.css. Javascript can also be added using the Embed Element. Do add Javascript, you can try this:

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

To avoid using to many elements, simply add the Javascript code below the HTML code, like this:

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

The HTML code can be placed via "embed code" element. The CSS can be inserted to your site/page/lay out header but remember to enclose it with <style></style>. But you can also add the CSS on the main-style.css. The JS or JavaScript (and other JQueries) can be placed on header/ footer code box enclosed with <script></script>.

That's the simplest explanation. More detailed explanation on: http://www.myweeblytricks./2014/01/3-ways-in-editing-weeblys.html

You can add your js code to the custom.js file in weebly files.enter image description here

本文标签: javascriptAdding code into weeblyStack Overflow