javascript - 如何使用 jQuery 添加一个特定的 HTML block

标签 javascript jquery html

我正在尝试使用 jQuery 添加 html block ,但无论我尝试什么,我都无法正确添加它。我想在单击“添加”按钮(Addfield 按钮)时复制并粘贴一个特定的 html block 。我不想克隆,一键添加一个字段就可以了。一次又一次...希望您能帮助我,提前致谢。

HTML:

<div class="entry-edit">
<div class="entry-edit-head">
    <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('panel')->__('Kategoriler') ?></h4>
    <button id="Addfield" title="Field Ekle" type="button" class="smclass"   onclick="" style="float: right;"><span><span><span>Field Ekle</span></span></span></button>
</div>
<fieldset id="grop_fields">

    <table cellspacing="0" class="form-list">

    <tr>
    <td class="label"><label for="Type">Tip</label></td>
    <td class="value">
    <select id="Type" name="optional[1][type]" class=" select">
    <option value="0">Date</option>
    <option value="1">Text</option>
    <option value="2">Select</option>
    </select>
    </td>
    </tr>
    <tr>
    <td class="label"><label for="Class">Class</label></td>
    <td class="value">
        <input id="Class" name="optional[1][class]" value="" type="text" class=" input-text">            </td>
    </tr>
    </table>

    <button id="Add" title="Ekle" type="button" class="scalable save" onclick=""  style=""><span><span><span>Ekle</span></span></span></button>
    <br></br>

</fieldset>

enter image description here

最佳答案

你可以这样做:

var html_code = '<span>put your full code here</span>';
var selector = 'body'; 
//change selector with where you want to append your html code into..
$(selector).append(html_code);

关于javascript - 如何使用 jQuery 添加一个特定的 HTML block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25385598/

相关文章:

javascript - 限制菜单中的元素并在单击下一步按钮时显示

javascript - 如何柯里化(Currying) jQuery 方法——哪个 `this` 值将传递 jQuery 对象?

javascript - 在使用 html 代码通过 id 自动定位元素以发送键时,某些值在站点的每次刷新中都会发生变化

jQuery Animate Div 向后调整大小

java - 移动网络应用程序的表单字段中的文件上传

javascript - 根据特定标签将 HTML 字符串拆分为多个部分?

javascript - paper-ripple 正在监听其容器外的点击事件

jquery ajax 函数不工作

javascript - 根据预设 "div"和 "width"的内容动态更改 "height"的高度

javascript - 使用特殊字符时无法获得 if ... else 语句来正确切换 ("⏶/⏷")