用append()附加大块html [英] Appending large block of html with append()

查看:123
本文介绍了用append()附加大块html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用jquery的append()追加大块文本。

  $('#add_contact_btn')。click(function(event){
event.preventDefault();

var large ='< div class =accordian_container>< a href =#class =accordian_trigger>< h4&co4借助信息< / h4>< / a>< hr />< div class =accordian_itemid =accord_item_2>< label>名字< / label>< br />< input type =text/> < br>< label>中间名< / label>< br />
< input type =text/>< br />
<标签>姓氏< / label>< br />
< input type =text/>< br />
< label>首页号码< / label>< ;
< input>" text>< br>
< label>工作编号< / label>< br />
< input type =text/>< br>
< label>单元编号< / label>< br />
< input type =text /><峰; br>
< / div>
< / div>';

$('#accordion_container')。append(large);



});

它看起来并不工作,并且在查看append()的文档后,我可以不知道为什么 - 有什么想法?是否有大量的HTML我试图追加?

解决方案

删除换行符。



http://jsfiddle.net/DmERt/

  var large ='< div class =accordian_container>< a href =#class =accordian_trigger>< h4>协同借贷信息< / h4>< / a>< hr />< div class =accordian_itemid =accord_item_2>< label> < br>< br />< input type =text/>< br />< label> Middle Name< / label>< br />< input type = text/>< br>>< label> Last Name< / label>< br />< input type =text/>< br />< label> < / label>< br />< / type =text/>< br>< label>工作编号< / label>< br />< input type = >< br>< label>< />< label>< / div>< / div>< / div>< / div>< 

$('#accordion_container')。append(large);


Im trying to append a large block of text using jquery's append().

$('#add_contact_btn').click(function(event) {
    event.preventDefault();

    var large = '<div class="accordian_container"><a href="#" class="accordian_trigger"><h4>Co-Borrower Information</h4></a><hr/><div class="accordian_item" id="accord_item_2"><label> First Name</label><br/><input type="text"/><br/><label>Middle Name</label><br/>
            <input type="text"/><br/>
            <label>Last Name</label><br/>
            <input type="text" /><br/>
            <label>Home Number</label><br/>
            <input type="text"/><br>
            <label>Work Number</label><br/>
            <input type="text"/><br>
            <label>Cell Number</label><br/>
            <input type="text"/><br>
            </div>
            </div>';

    $('#accordion_container').append(large);



});

It doesn't seem to be working and after looking at the documentation for append(), I can't figure out why - any ideas? Is it the large amount of HTML that I am trying to append?

解决方案

Remove the line breaks.

http://jsfiddle.net/DmERt/

var large = '<div class="accordian_container"><a href="#" class="accordian_trigger"><h4>Co-Borrower Information</h4></a><hr/><div class="accordian_item" id="accord_item_2"><label> First Name</label><br/><input type="text"/><br/><label>Middle Name</label><br/><input type="text"/><br/><label>Last Name</label><br/><input type="text" /><br/><label>Home Number</label><br/><input type="text"/><br><label>Work Number</label><br/><input type="text"/><br><label>Cell Number</label><br/><input type="text"/><br></div></div>';

$('#accordion_container').append(large);​

这篇关于用append()附加大块html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆