简体   繁体   English

在Tritium中,我该如何改变所有 <p> 标签到 <div> 标签?

[英]In Tritium, how do I transform all <p> tags to <div> tags?

I'm working in the Moovweb SDK and am optimizing my personal desktop site for mobile. 我正在使用Moovweb SDK并正在优化我的移动个人桌面网站。

How do I transform all my <p> tags to <div> tags? 如何将所有<p>标签转换为<div>标签? I really don't want to do it manually! 我真的不想手动做! Search and replace?? 搜索和替换? haha 哈哈

You can use the name() function to change the name of an element. 您可以使用name()函数更改元素的名称。 For example: 例如:

$("//p") {
    name("div") 
}

See it in action here: http://tester.tritium.io/bd1be4f2c187aed317351688e23f01127d26343a 请在此处查看: http//tester.tritium.io/bd1be4f2c187aed317351688e23f01127d26343a

Cheap way: Add p{margin:0} to your CSS, this will remove the only special styling of <p> tags making them look like <div> s. 便宜的方法:在你的CSS中添加p{margin:0} ,这将删除<p>标签的唯一特殊样式,使它们看起来像<div> s。

This is only a visual effect, though. 但这只是一种视觉效果。 For instance, you're still not allowed to put a <form> inside a <p> , even with the above CSS. 例如,即使使用上面的CSS,你仍然不允许在<p>放置<form> If that's what you're after, a simple search and replace will do: 如果这就是您所追求的,那么简单的搜索和替换将会:

  • Replace <p> with <div> <p>替换为<div>
  • Replace <p␣ (left angle, p, space) with <div␣ (there's a space at the end of that one too) 替换<p␣ (左角,P,空间)与<div␣ (有一个在该一个端部的空间太)
  • Replace </p> with </div> </p>替换为</div>

That should do it! 应该这样做!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM