0

我正在使用 jquery 步骤向用户显示表单,但我遇到了 content 属性的一些奇怪问题。

如果我" "在一行代码中同时拥有这两个步骤,那么这些步骤将起作用。

但是,如果我"通过添加另一个输入字段将结束移动到另一行,则不会呈现这些步骤。

$("#wizard").steps({
    headerTag: "h3",
    bodyTag: "fieldset",
    transitionEffect: "slideLeft",
    onStepChanging: function(event, currentIndex, newIndex) {

    //only apply to first step

    if (currentIndex === 0 && ($("#workType > option:selected").val()) === "1") {

        $("#wizard").steps("insert", 1, {
            title: "Construction Details",
            content: "<input type='text' name='budget' id='budget' placeholder='What is your budget?'><br/>"
        });
    }
});

所以这有效:

content: "<input type='text' name='budget' id='budget' placeholder='What is your budget?'><br/>"

这不会:

 content: "<input type='text' name='budget' id='budget' placeholder='What is your budget?'>
           <input type='text' name='timeline' id='timeline' placeholder='When do you want to start?'>
                            <br/>"

内容是否需要全部放在一行上还是我做错了什么?TIA

4

1 回答 1

2

您可以尝试使用以下方式连接字符串+

content: "<input type='text' name='budget' id='budget' placeholder='What is your budget?'>" + 
           "<input type='text' name='timeline' id='timeline' placeholder='When do you want to start?'> +
           "<br/>";

或其他方式:

var content_str = [
    '<input type='text' name='budget' id='budget' placeholder='What is your budget?'>',
    '<input type='text' name='timeline' id='timeline' placeholder='When do you want to start?'>',
    '<br />'
].join('');
...
contnet: content_str
于 2014-07-10T05:33:33.847 回答