Change ID to text in paragraph with jQuery
- by Reuben
I would like to take what text is in my p tag and make that the p tags parent (div) that ID. I would also like to add a _ for any spaces in the p tag.
Example:
<div class="circle"><p>Apple</p></div>
<div class="circle"><p>Banana</p></div>
<div class="circle"><p>Carrot Juice</p></div>
to
<div id="Apple" class="circle"><p>Apple</p></div>
<div id="Banana" class="circle"><p>Banana</p></div>
<div id="Carrot_Juice" class="circle"><p>Carrot Juice</p></div>