I have multiple files in different directories which i am able to iterate but i m unable to add new attribute properly.
My file.js contains below code
<div id='storage'>
<div className='style-sub-content style-pt-12'>
<div className='style-inline-block style-text-left style-mb-8'>
<div className='style-text-center style-mr-8'>
<button className={'button-common-style common-button-normal style-element-240x44 ' + this.checkEnable('store')}
onClick={() => this.applyStorageType('store')}
>
{this.props.name}
</button>
</div>
</div>
</div>
which i want to change to below (adding a new attribute with file name and a unique number starting 0).
<div id='storage'>
<div className='style-sub-content style-pt-12' data-myID='filename-1'>
<div className='style-inline-block style-text-left style-mb-8' data-myID='filename-2'>
<div className='style-text-center style-mr-8' data-myID='filename-3'>
<button data-myID='filename-4' className={'button-common-style common-button-normal style-element-240x44 ' + this.checkEnable('store') }
onClick={() => this.applyStorageType('store')}
>
{this.props.name}
</button>
</div>
</div>
</div>
Any idea how do i achieve this ? Reading all files in a folder and adding a new attribute to all HTML tags which should be ‘filename-uniqueno’(number starts from 1 and increments)