Skip to content
Advertisement

replace li tag with different tag according to the bullet level

need to replace the li tags with different customized tag according to the bullet level, For the li level1 keep it as is, for level2 change li to lii, for level3 change li to liii

For example for the input below (I have only 2 bullet levels in the below code just as example)

JavaScript

desired output

JavaScript

as you can see the code should change only 2 lines (as it’s level 2) and keep li level1 as is

JavaScript

my code in php

JavaScript

Update

1- the html code is created by tinymce and stored in DB 2- I am using FPDF to output the DB to PDF file 3- I am using a specific library to FPDF to parse the html tags to have a specific style for each tag

Instead of devoting the questions, it’s better if you try to help if you can, and keep it as is if you don’t have anything to provide.

Advertisement

Answer

I reviewed my code and it works fine now, for the FPDF – witetag library purpose I removed the UL tags and closed each li tag at the end of the line, kept other tags as is.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement