- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用Jquery
保存在html_data
变量HTML
代码中。特别是
Jquery(document).ready(function(){
html_data = $('.row').html();
)};
<div class = "row">
<div class = "col-md-12">
<select multiple="multiple" id ="sel1">
<option value="1"> Element1 </opion>
<option value="2"> Element2 </opion>
<option value="3"> Element3 </opion>
</select>
</div>
</div>
<div class ="before"></div>
然后我在 Jquery
中有一个我编写的函数
function newRow(){
new_html = html_data;
$(new_html).find('select').attr('name', 'myNewSelect');
$(new_html).insertBefore('.before');
}
已创建具有选择多个
的新行
,但未设置属性名称。我该如何做到这一点?
最佳答案
您不需要获取.row
元素的html()
。您可以使用jquery的.clone()
方法,然后使用相同的.insertbefore()
方法将其附加在.before
之前
function newRow(){
var new_html = $('.row .col-md-12').clone(true);
new_html.insertBefore('.before');
new_html.find('select').attr('name', 'myNewSelect');
}
这是 fiddle :https://jsfiddle.net/eL43e2vs/
关于javascript - 在 HTMLString 中找到的元素中设置 attr(name),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32285422/
var $fragment = $(" "); $("#x").text($fragment.length); 看到这个 fiddle ...... http:/
ASP.NET MVC 的优势 或 ?为什么? 最佳答案 如果它返回 MvcHtmlString 则无所谓; <%:会知道它是预转义的。因此,我会使用 <%:这样审稿人就不需要考虑“这是转义了吗?
我试图在 WkWebView 中显示我之前下载并存储在字符串中的 html 页面。 这就是我设置 WkWebView 的方式: webView = WKWebView(frame: self.
我正在努力升级一些使用 jQuery 1.7.2 版的旧软件。由于添加了一些新插件并且需要更新版本的 jQuery,我已将其升级到版本 1.12.1。 然而,有大量使用 jQuery(htmlStri
appendTo 的 API 文档列出可以为目标选择一个 HTML 字符串的方法。 但是,这似乎没有用,因为该集合仍然包含原始元素,并且 HTML 字符串似乎没有添加到 DOM 中的任何地方,我也看不
我稍微玩了一下 jQuery,然后有了一个想法,所以我决定试一试。 $('table').append(''); 如你所想,这产生了: table -thead --tr ---th ---th --
本类(class):HtmlString html = $html; } /** * Get the HTML string. * * @return string
我正在查看 MvcHtmlString 及其基类 HtmlString 的源代码,它们似乎都是字符串的无用包装器。 我记得有一次我做过这个练习并看到了好处,但现在想不起来了。当时我花了很多时间研究 M
当我尝试从 HTML 生成 PDF 时,一些土耳其语字符如 ĞÜŞİÖÇ ğüşıöç PDF 中缺少这些字符,我看到一个空格代替了这些字符,但我想打印该字符。 我的代码是: public virt
HtmlString 与 MvcHtmlString 这两者之间有什么区别,或者什么时候更喜欢其中一个? 编辑: 与 HtmlString 相比,MvcHtmlString 更受青睐的是 MvcHtm
我使用Jquery保存在html_data变量HTML代码中。特别是 Jquery(document).ready(function(){ html_data = $('.row').htm
它是一个在 Visual Studio 2017 上运行的 .Net Core 2.0 应用程序我想显示在 View 上返回的 HTML 字符串。 我添加了Microsoft.AspNetCore.H
如果是 ajax 请求,我有一个方法可以将 javascript 添加到部分 View 的末尾。但我的问题是,当返回脚本时,脚本标签已被删除,我要执行的函数是用纯文本编写的。 if (httpCont
我有一个函数可以做到这一点: document.body.innerHTML += 'lorem ipsum'; 它工作正常,但它破坏了我对其他 div 的引用(我读到这是因为它再次解析正文)。是否有
我有一个从 sqlite 数据库读取数据的应用程序,使用此方法读取数据并将其包含在对象中....我用 NSLog 进行了检查 #import "ViewController1.h" #import "
只是我想在我的对象中有一个属性序列化为字符串而不是 HtmlString(它是)。 这里的原因是对象在 json 中被序列化,toString 函数返回的不是对象的字符串内容,而是“[object O
我有一个包装器,只要字段有值,它就会将标题添加到字段中。该字段实际上是一个字符串,它包含来自 tinymce 文本框的 HTML。 要求:当字段为空或只有空格时,标题不应显示。 问题:html 中的空
你好, 我正在显示一个 html 页面,其中包含一个带有一些输入文本字段和一个提交按钮的表单。 如果我使用 loadRequest 显示页面: 一切正常。 如果我使用 loadHTMLString:b
我创建了一个宏来处理表单错误,如下所示: {% macro render_field_with_errors(field) %} {{ field.labe
我发出了一个http请求并收到了一个htmlString,现在我想将其转换为Dom对象以查询其元素。谢谢你的帮助 最佳答案 您可以创建一个容器对象(我在这里使用了 div),然后将您的 html 字符
我是一名优秀的程序员,十分优秀!