简体   繁体   English

如何获得像这样的元素。 h1从数据传递到视图

[英]How to get element like eg. h1 from data passed to view

I have to fetch one element from data passed to view. 我必须从传递给视图的数据中获取一个元素。 I have div with content like this: 我有div这样的内容:

<div class="disc" id="content">
    {!! $clause->contents !!}
</div>

It shows some text where i have element with heading 1 - h1. 它显示了一些文本,其中我有标题为1 - h1的元素。 How can I fetch only this h1 element which I could use in somewhere else in view? 我怎样才能获取我可以在视图中的其他地方使用的这个h1元素?

Better practice would be to have additional column for that heading in your database. 更好的做法是在数据库中为该标题添加额外的列。 Eg. 例如。 $clause->title or $clause->heading , but since you're dealing with that problem you will have to extract that heading through DOM parser. $clause->title$clause->heading ,但由于你正在处理这个问题,你必须通过DOM解析器提取该标题。

You can find detailed solution to this on this question which you can integrate into your controller. 您可以在问题上找到详细的解决方案,您可以将其集成到控制器中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在iframe中使用jQuery确定元素的祖先(例如,当我们检查元素以在Firebug中查看时,它会显示完整路径) - how to determine an element’s ancestors with jQuery in an iframe (eg. like when we do inspect element to view in firebug it shows the full path) 将一个元素(例如H2)拖到div,但contenteditable无效 - Drag an element(H2 eg.) to div, but contenteditable is invalid 如何使用JQuery从另一个文档中的H1交换H1元素 - How to swap an H1 element from an H1 in another document using JQuery 如何显示按钮[例如 查看,编辑,删除]在flexigrid中 - How to display buttons[eg. view,edit,delete] in flexigrid 如何在此弹出框中获取 HTML 格式化文本,如:<li> _ _ _ _</li><br><h1> _ _ _ _</h1> ETC - How can i get HTML Formated text in this popup box Like: <li> _ _ _ _</li> <br> <h1> _ _ _ _</h1>etc Websocket 数据出现在 h1 元素中,但不在输入中 - Websocket data is appearing in an h1 element, but not in an input 如何使用jquery从h1标签的属性获取值? - How to get value from attribute of h1 tag using jquery? 如何查找元素中是否包含h1元素? - How can I find if an element has an h1 element inside it? Jquery - 如何将元素的父元素从H1更改为P? - Jquery - How do I change the parent of an element from an H1 to a P? 无法在DOM中获取h1元素的text / innerHTML - Can't get text/innerHTML of h1 element in DOM
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM