coldfusion向某些类添加一个id [英] coldfusion add an id to certain classes

查看:204
本文介绍了coldfusion向某些类添加一个id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我有一堆HTML存储在一个变量,我输出到页面看起来像这样:

Currently I have a bunch of HTML stored in a variable that I am outputting to the page that looks a little like this:

<p class="firstpara">some stuff</p>
<p class="subhead">a heading</p>
<p class="subsubhead">a subheading</p>
<p>wording and such</p>
<p class="subsubhead">another subheading</p>

你会得到想法。

输出如下:

<cfoutput>
#request.oEntry.getHTMLStuff()#
</cfoutput>

无论如何,我需要找到所有类的subsubhead,并添加一个id =x其中x对应于该子标题的数据库id。

Anyway, I need to find all classes of "subsubhead" and add in a id="x" where x corresponds to a database id i have for that subheading.

我认为这最好在Coldfusion中完成,因为数据库id已经保存在cfquery和i Can不会混用和匹配jQuery和ColdFusion。

I think this would be best done in Coldfusion since the database id is already held in a cfquery and i Can't mix and match jQuery and ColdFusion.

目前不确定最好的方法。

not currently sure the best way to do this.

推荐答案

这是我想出来的代码。

<cfscript>
local.string    = request.oEntry.getEditorial();
local.x         = 0; 
do{
    local.x = REFind("Subsubhead", local.string,local.x);
    if(local.x neq 0){
        local.x = local.x+10;
        local.string = insert(" id='x'",local.string,local.x);
    }

} while(local.x neq 0);

</cfscript>

这适用于我,但可能有更好的方法

This works for me, but there might be a better way

这篇关于coldfusion向某些类添加一个id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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